[issue40801] Expose PyFloat_ToDouble at Python level: operator.as_float?

2020-05-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think an alternative constructor is the best option. Some time ago I proposed to add more alternative constructors: https://mail.python.org/archives/list/python-id...@python.org/thread/5JKQMIC6EUVCD7IBWMRHY7DRTTNSBOWG/ --

[issue40801] Expose PyFloat_ToDouble at Python level: operator.as_float?

2020-05-28 Thread Mark Dickinson
Mark Dickinson added the comment: On naming, maybe float.from_number or float.from_numeric? -- ___ Python tracker ___ ___

[issue40801] Expose PyFloat_ToDouble at Python level: operator.as_float?

2020-05-28 Thread Mark Dickinson
Mark Dickinson added the comment: > `operator` seems a slightly odd place for this. Yes, it's not ideal. It's by analogy with operator.index, which provides the equivalent duck-typing for integers, and calls __index__. Similarly, operator.as_float is primarily there to call __float__,

[issue40801] Expose PyFloat_ToDouble at Python level: operator.as_float?

2020-05-28 Thread Zachary Ware
Zachary Ware added the comment: `operator` seems a slightly odd place for this. My naive expectation would be that `float(floatlike_obj)` should do what you want, but it seems that's not the case (too permissive of input types?). So then, what about an alternate constructor on the float

[issue40801] Expose PyFloat_ToDouble at Python level: operator.as_float?

2020-05-28 Thread Mark Dickinson
Mark Dickinson added the comment: Proof of concept in GH-20481 -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue40801] Expose PyFloat_ToDouble at Python level: operator.as_float?

2020-05-28 Thread Mark Dickinson
Change by Mark Dickinson : -- keywords: +patch pull_requests: +19730 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20481 ___ Python tracker ___

[issue40801] Expose PyFloat_ToDouble at Python level: operator.as_float?

2020-05-28 Thread Mark Dickinson
Change by Mark Dickinson : -- title: Expose PyFloat_ToDouble at Python level: operator.to_float? -> Expose PyFloat_ToDouble at Python level: operator.as_float? ___ Python tracker