-
Notifications
You must be signed in to change notification settings - Fork 176
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
Remove bitcount field of the mpf tuple? #720
Comments
The tricky thing is that the mpf tuple is used as a conversion format in many places so there would still be a need to generate the 4-tuple with bit count often. Otherwise though I agree that a 3 tuple is better and it can save a lot of wasted arithmetic (and bugs) trying to keep the bit count in sync. |
The proposed change is obviously not a backward compatible, so we will accept 4-tuples for a while, e.g. in
But maybe we miss some scenarios where "caching" the bitcount has some benefits? (Same for the sign bit, BTW.) |
BTW, simpler format (2-tuple) was planned in #178. So, I guess Fredrik is ok with this idea. |
Currently, we use bc for special numbers (nan, inf, etc), but this seems redundant as well. |
It seems, some mpmath users (well, the SymPy of course!) actually do tuple unpacking of mpf's. I think we should deprecate this in the next release. from_man_exp/to_man_exp() functions should be used instead. |
Ok. The plan is to deprecate direct manipulations with Unfortunately, we can't emit a warning at runtime. I'll make a patch for the Diofant to show how it's possible. It seems, very few places are affected. I think it's valid to the SymPy as well. Edit: diofant/diofant#1389 BTW, maybe we should change |
Ok, I guess, there are no fans of the bc field. That's missing here is a warning in release notes for v1.4, that direct access to mpf tuple is deprecated. |
Our docs says:
Since CPython 3.1 there is a such function. It's the int.bit_length() method.
Some timings:
vs
So, using the bit_length() is clearly better and it's available for all backends. Does it make sense to keep now the bc field of the mpf tuple or it should be deprecated?
The text was updated successfully, but these errors were encountered: