Mark Dickinson added the comment:
> Maybe use PyNumber_Check() [...]
Ah, that works. It reads better than the `PyFloat_AsDouble` solution, too,
since it's far from obvious that `PyFloat_AsDouble` goes to the trouble to
coerce a float-y thing to a float.
I did some searching around to see if
Serhiy Storchaka added the comment:
For converting a string to a float there is PyFloat_FromString(). So that this
part of functionality of PyNumber_Float() is redundant. In long perspective it
would be worth to deprecate it.
--
___
Python tracker
Serhiy Storchaka added the comment:
Maybe use PyNumber_Check() to distinguish these two cases?
if (PyNumber_Check(obj))
return PyNumber_Float(obj);
PyErr_SetString(PyExc_TypeError, "not a number");
return NULL;
--
nosy: +serhiy.storchaka
___
New submission from Mark Dickinson :
Our abstract objects layer in the C-API includes PyNumber_Float [1], which is
equivalent to a Python-level `float` call, including the behaviour of accepting
strings. I'm not convinced that it's a particularly useful function: I suspect
that it's more commo