diff options
author | Guido van Rossum <guido@python.org> | 1996-01-12 01:21:14 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-01-12 01:21:14 (GMT) |
commit | cf3d1087d1285be03a1e450a39130aea74890c67 (patch) | |
tree | b41323df93a1830bdcb136834a1800807f11e7bc /Objects | |
parent | ff4af06735817a768733fa3eeb598f87c51e20f7 (diff) | |
download | cpython-cf3d1087d1285be03a1e450a39130aea74890c67.zip cpython-cf3d1087d1285be03a1e450a39130aea74890c67.tar.gz cpython-cf3d1087d1285be03a1e450a39130aea74890c67.tar.bz2 |
Added PyComplex_AsCComplex
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/complexobject.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 8299b0b..20eab1e 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -208,6 +208,18 @@ PyComplex_ImagAsDouble(PyObject *op) { } } +complex +PyComplex_AsCComplex(PyObject *op) { + complex cv; + if (PyComplex_Check(op)) { + return ((PyComplexObject *)op)->cval; + } else { + cv.real = PyFloat_AsDouble(op); + cv.imag = 0.; + return cv; + } +} + static void complex_dealloc(op) object *op; |