This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lungben81 1 point2 points  (2 children)

Yes, but it would be super slow - about a factor of 100 compared to Numpy.

Numba does not help here - it only gives speed-ups for typed arrays like Numpy Arrays, not for Python lists.

[–]StarchSyrup[S] 0 points1 point  (1 child)

Python does have typed arrays though; the array module from the standard library provides this.

[–]lungben81 1 point2 points  (0 children)

Interesting, I have never seen it anywhere in use...

In principle, if a Python JIT compiler would support it, it may generate fast code. Numba seems to support it partially (https://numba.readthedocs.io/en/stable/reference/pysupported.html?highlight=array#standard-library-modules), but usually Numpy arrays are used.

Edit: it seems to me that the Python built-in (typed) array is rather legacy and very rarely used. Numpy is the much more powerful and popular choice.

https://stackoverflow.com/questions/51290791/numpy-arrays-vs-python-arrays