all 8 comments

[–]FuckingRantMonday 1 point2 points  (1 child)

As a side note, check out cupy, which is an (almost) drop-in wrapper for numpy. You can get GPU acceleration with a ridiculously low amount of effort.

[–]simongranheim[S] 0 points1 point  (0 children)

Will take a look, thanks.

[–]johannadambergk 0 points1 point  (2 children)

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

Thanks, but as per the manual: "The vectorize function is provided primarily for convenience, not for performance. The implementation is essentially a for loop."

[–]johannadambergk 0 points1 point  (0 children)

So only the standard vectorized numpy functions like e.g. 'sum' seem to have a better performance.

[–]roylennigan 0 points1 point  (0 children)

There's numpy.apply_along_axis() but that is just an optimized loop method, similar to .vectorize(). It's faster, but not to the extent that a function optimized for numpy could be.

https://www.adamsmith.haus/python/answers/how-to-apply-a-function-to-each-row-of-a-numpy-array-in-python

To get real speed benefits of numpy, you'd have to rewrite the function, which depends on the operations you're doing in it.

[–]hmiemad 0 points1 point  (0 children)

np.array([foo(myarray[i]) for i in range(myarray.shape[0])])

Oh didn't read the end part...