[Python-ideas] Re: Expose PyFloat_AsDouble to Python

2020-05-29 Thread Serhiy Storchaka
29.05.20 14:22, Serhiy Storchaka пише: I prefer it to be an alternative float constructor. We can also add the corresponding constructor for complex, and add constructors which accept only str, bytes or bytes-like object (i.e. parse a text representation of the number). See also previous discus

[Python-ideas] Re: Expose PyFloat_AsDouble to Python

2020-05-29 Thread Antoine Pitrou
On Fri, 29 May 2020 09:48:53 - "Mark Dickinson" wrote: > > I have a proof-of-concept PR [1] that exposes this in the `operator` module > as `operator.as_float`. See also the discussion on the tracker [2]. `operator.as_float` sounds good to me. There's the `operator.index` precedent. Regar

[Python-ideas] Re: Expose PyFloat_AsDouble to Python

2020-05-29 Thread Serhiy Storchaka
29.05.20 12:48, Mark Dickinson пише: 2. Call the object's `__float__` method. But this is fraught with peril, too: for a proper equivalent, you need to be careful to look up `__float__` on the type, not the object itself. And then a new version of Python changes `PyFloat_AsDouble` to also acce