Skip to content

[3.12] gh-121834: Improve complex C-API docs (GH-121835)#121897

Merged
sobolevn merged 3 commits intopython:3.12from
sobolevn:backport-72dccd6-3.12
Jul 17, 2024
Merged

[3.12] gh-121834: Improve complex C-API docs (GH-121835)#121897
sobolevn merged 3 commits intopython:3.12from
sobolevn:backport-72dccd6-3.12

Conversation

@sobolevn
Copy link
Member

@sobolevn sobolevn commented Jul 17, 2024

(cherry picked from commit 72dccd6)

Since PyComplex_RealAsDouble uses PyFloat_AsDouble, it can still fail there:

double
PyComplex_RealAsDouble(PyObject *op)
{
if (PyComplex_Check(op)) {
return ((PyComplexObject *)op)->cval.real;
}
else {
return PyFloat_AsDouble(op);
}
}

While PyComplex_ImagAsDouble is always successful:

double
PyComplex_ImagAsDouble(PyObject *op)
{
if (PyComplex_Check(op)) {
return ((PyComplexObject *)op)->cval.imag;
}
else {
return 0.0;
}
}


📚 Documentation preview 📚: https://cpython-previews--121897.org.readthedocs.build/

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants