Description
Feature or enhancement
Proposal:
Maybe it should be discussed first in the C-API WG, but this case seems more or less obvious for me.
No C-API function exists to create complex numbers from string. This is available on C-level only with using pure-Python API. All others builtin numeric types have a dedicated API for this (PyFloat_FromString() and PyLong_FromString()). Proposal - float-like:
PyObject* PyComplex_FromString(PyObject *str)
In stdlib this can be used e.g. to solve #98485.
Similarly for PyNumber_Complex()
, complex numbers apparently are part of the Number Protocol: i.e. PyNumber_Check() is true for them and they support most it's API functions. Why there is no PyNumber_Complex()
, which would be working like PyNumber_Long() and PyNumber_Float()? Proposal:
PyObject* PyNumber_Complex(PyObject *o)
An equivalent of complex(o)
.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response