[SciPy-Dev] numba simple example
Dieter Werthmüller
Dieter at Werthmuller.org
Wed Jul 3 16:19:28 EDT 2019
Just as information, might be useful.
I remember that it was discussed something over a year ago whether or
not having numba as a dependency. I think it was Ralf who said that it
would be nice if one could achieve with a simple decorator a speed-up
with numba - if it is installed, and otherwise just keep the status quo.
The following simple wrap resulted in a speed-up of a factor 2; the
speed up was pretty constant (in my short tests) for arrays say from a
couple of ten-thousands to 1e9 complex elements; for smaller array the
gain was even higher.
@nb.njit(nogil=True, fastmath=True, cache=True)
def l2norm(x):
"""Jitted version of np.linalg.norm(x, ord=None)."""
return np.linalg.norm(x)
Again, just for the record, for future discussions on the topic.
More information about the SciPy-Dev
mailing list