Mir vs. Numpy: Reworked!

Andre Pany andre at s-e-a-p.de
Thu Dec 3 16:50:39 UTC 2020


On Thursday, 3 December 2020 at 16:27:59 UTC, 9il wrote:
> Hi all,
>
> Since the first announcement [0] the original benchmark [1] has 
> been boosted [2] with Mir-like implementations.
>
> D+Mir:
>  1. is more abstract than NumPy
>  2. requires less code for multidimensional algorithms
>  3. doesn't require indexing
>  4. uses recursion across dimensions
>  5. a few times faster than NumPy for non-trivial real-world 
> applications.
>
> Why Mir is faster than NumPy?
>
> 1. Mir allows the compiler to generate specialized kernels 
> while NumPy constraints a user to write code that needs to 
> access memory twice or more times.
>
> Another Mir killer feature is the ability to write generalized 
> N-dimensional implementations, while Numpy code needs to have 
> separate implementations for 1D, 2D, and 3D cases. For example, 
> the main D loop in the benchmark can compile for 4D, 5D, and 
> higher dimensional optimizations.
>
> 2. @nogc iteration loop. @nogc helps when you need to control 
> what is going on with your memory allocations in the critical 
> code part.
>
> [0] 
> https://forum.dlang.org/post/pemharpztorlqkxdooul@forum.dlang.org
> [1] https://github.com/typohnebild/numpy-vs-mir
> [2] https://github.com/typohnebild/numpy-vs-mir/pull/1
>
> The benchmark [1] has been created by Christoph Alt and Tobias 
> Schmidt.
>
> Kind regards,
> Ilya

Hi Ilya,

Thanks a lot for sharing the update. I am currently working on 
porting a python package called FMPY to D. This package makes 
usage of numpy and I hope I can use MIR here.

Somehow it is hard to get started to learn MIR. What maybe could 
help python developers is to have some articles showing numpy 
coding and side by side the equivalent MIR coding.

What I miss in MIR is a function to read and write CSV files. Is 
s.th. like numpy.genfromtxt planned?

Kind regards
Andre


More information about the Digitalmars-d-announce mailing list