-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quantity.decompose()
is slower than Quantity.to()
#1641
Comments
What about |
Optimizations with regards to units has come up multiple times in the past. This is a very good page to take a look at: |
About 20% difference between best and worst. |
So maybe the issue is that new code doesn't obey the optimizations that were already decided on. I don't see recommendations in the coding style doc. |
I think this is the case. The various Unit conversion conventions are used liberally in the code. This is the case even in the case of core functionality like the TimingModel class. |
I tried this. There is significant difference in performance. |
A while ago, I did a profiling run on PINT, and found that the performance issues of PINT arises from a large number of factors. One of the culprits was the frequent use of
Quantity.decompose()
function andQuantity.to()
function with a string argument.Here is a simple comparison:
%timeit (dmu*DMconst).decompose()
%timeit (dmu*DMconst).to("Hz")
%timeit (dmu*DMconst).to(u.Hz)
In this case,
decompose()
is slower by 40%.I think we should change
decompose()
toto()
wherever possible.The text was updated successfully, but these errors were encountered: