This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson, serhiy.storchaka, zach.ware
Date 2020-05-28.18:08:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590689322.97.0.144712197022.issue40801@roundup.psfhosted.org>
In-reply-to
Content
> So such conversion looks to me less useful than operator.index().

That may be true, but it's still useful, and currently very hard to write without core Python support. The problem is that duck-typing for something float-like is easy and widespread in the Python C code (in the math module, in float formatting, in *any* function that uses the "d" converter with PyArg_ParseTuple), but it's hard to correctly spell the equivalent in pure Python.

I've needed this in a few places. Most recently, I needed it for the Enthought Traits library: the "Float" trait type accepts something float-like and needs to convert it to something of exact Python type float. (That float is then often consumed by other third-party libraries that can't reliably be expected to do their own duck-typing.)

It would also be useful when trying to create pure Python equivalents for modules written in C (e.g., for things like datetime and decimal). Where the C code uses PyFloat_AsDouble, there's really no equivalent that can be used in Python.
History
Date User Action Args
2020-05-28 18:08:43mark.dickinsonsetrecipients: + mark.dickinson, zach.ware, serhiy.storchaka
2020-05-28 18:08:42mark.dickinsonsetmessageid: <1590689322.97.0.144712197022.issue40801@roundup.psfhosted.org>
2020-05-28 18:08:42mark.dickinsonlinkissue40801 messages
2020-05-28 18:08:42mark.dickinsoncreate