gh-84978: Add float.from_number() and complex.from_number()#26827
gh-84978: Add float.from_number() and complex.from_number()#26827serhiy-storchaka merged 9 commits into
Conversation
They are alternate constructors which only accept numbers (including objects with special methods __float__, __complex__ and __index__), but not strings.
d54d0ef to
f3e83a4
Compare
June 21, 2021 12:58
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
|
@serhiy-storchaka Are you still interested in pursuing this? Looks like it's still a draft; what's needed to make it ready for review? |
Sorry, something went wrong.
|
It needs documentation. I'll write it if the rest be set. It differs from your original idea (class methods instead of Should we add also special constructors for parsing? |
Sorry, something went wrong.
|
@serhiy-storchaka, some tests refactoring in test_float/complex is irrelevant for this pr. Can I port this as a separate pr? |
Sorry, something went wrong.
|
This tests refactoring in test_float/complex is required for testing |
Sorry, something went wrong.
I was thinking about similar refactoring while improving test coverage for the complexobject.c. So, maybe this could be useful regardless of the fate of this pr. |
Sorry, something went wrong.
|
@mdickinson I added docs and remove the draft status. Hope it will help with review. |
Sorry, something went wrong.
Taken from python#26827 Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
mdickinson
left a comment
There was a problem hiding this comment.
This LGTM, and works as expected in my manual testing. I only have a couple of grammar nitpicks.
Thank you!
Sorry, something went wrong.
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
…thonGH-26827) They are alternate constructors which only accept numbers (including objects with special methods __float__, __complex__ and __index__), but not strings.
They are alternate constructors which only accept numbers
(including objects with special methods
__float__,__complex__and
__index__), but not strings.https://bugs.python.org/issue40801