| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Proposed changes LGTM. For things of exact type float (and possibly also for float subclasses), I think we could dispense with the math_1_to_int complications to get even more speedup. But that doesn't have to happen in this PR.
Do we have tests for the various cases of floats, float subclasses that don't override __floor__, float subclasses that do override __floor__, things that aren't floats but provide a __float__ method, etc.? If not, would it be worth adding such tests?
Sorry, something went wrong.
It occurs to me that I don't know how a subclass of float that implements its own __float__ should behave. >>> class MyFloat(float): ... def __float__(self): ... return 9.0 ... >>> x = MyFloat(16) >>> math.sqrt(x) 4.0 >>> float(x) 9.0 |
Sorry, something went wrong.
|
I think that it would be better to not call __float__ for float subclasses, __int__ and __index__ for int subclasses, __complex__ for complex subclasses, __str__ for str subclasses, etc. We already have a content of corresponding class and can convert it to a C value or to a new Python instance. |
Sorry, something went wrong.
|
Thank you for your review @mdickinson, I addressed your comments and added tests. Could you please take another look? |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
https://bugs.python.org/issue38639