Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Speed up Unit.to when target unit is the same as original unit #7643
This was split out from #7616
In : from astropy.units import deg In : %timeit deg.to(deg) 3.69 µs ± 149 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In : from astropy.units import deg In : %timeit deg.to(deg) 542 ns ± 28.4 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
Hi there @astrofrog
Everything looks good from my point of view!
If there are any issues with this message, please report them here.
@astrofrog - thanks, this PR is certainly simple and safe. But I wonder if we shouldn't go a little further. My main reason is that using
Given this, I wonder if your
A question, then, is whether we can change the default in this way. In favour is my argument above that people are almost certainly using this to get a scale factor and thus will be getting wrong answers if equivalencies are in force. Against is that it changes the API and previously working code might now error (though, as said, I'm not sure that error isn't wanted!).
So, I think this would actually be a good change, but of course in principle we could also do something like:
But I must say I don't like that much. Instead, if you're unsure about my suggestion, maybe we can for now stick to the PR here, but replace