You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm experimenting a bit with pint in combination with Numpy and encountered a performance problem related to the order of operands in arithmetic operations with numpy arrays.
In [105]: a=np.linspace(-2, 2, 10_000)
In [106]: %timeitureg.m*a32.5µs ± 346nsperloop (mean ± std. dev. of7runs, 10,000loopseach)
In [107]: %timeita*ureg.m2.51ms ± 12.1µsperloop (mean ± std. dev. of7runs, 100loopseach)
Increasing the size of the array:
In [108]: a=np.linspace(-2, 2, 100_000)
In [109]: %timeitureg.m*a58.8µs ± 85.1nsperloop (mean ± std. dev. of7runs, 10,000loopseach)
In [110]: %timeita*ureg.m24.1ms ± 51.8µsperloop (mean ± std. dev. of7runs, 10loopseach)
Is this something that can be fixed or is there some good way to work around it?
Thanks for a very useful library!
The text was updated successfully, but these errors were encountered:
jokasimr
changed the title
Unexpected performance impact
Unexpected performance impact from order of operands
Jan 4, 2024
In this case, how does pint prevent ndarray.__mul__ from broadcasting the multiplication to every element?
Does it use __array_priority__ or something else?
Hi,
I'm experimenting a bit with pint in combination with Numpy and encountered a performance problem related to the order of operands in arithmetic operations with numpy arrays.
Increasing the size of the array:
Is this something that can be fixed or is there some good way to work around it?
Thanks for a very useful library!
The text was updated successfully, but these errors were encountered: