Message370258
> 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. |
|
Date |
User |
Action |
Args |
2020-05-28 18:08:43 | mark.dickinson | set | recipients:
+ mark.dickinson, zach.ware, serhiy.storchaka |
2020-05-28 18:08:42 | mark.dickinson | set | messageid: <1590689322.97.0.144712197022.issue40801@roundup.psfhosted.org> |
2020-05-28 18:08:42 | mark.dickinson | link | issue40801 messages |
2020-05-28 18:08:42 | mark.dickinson | create | |
|