Mercurial > cpython-lru_cache-weakref
diff Objects/complexobject.c @ 3328:4c655115dfce legacy-trunk
Added PyComplex_AsCComplex
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 12 Jan 1996 01:21:14 +0000 |
| parents | e5d1f242daf9 |
| children | 8209998d669e |
line wrap: on
line diff
--- a/Objects/complexobject.c Fri Jan 12 01:17:50 1996 +0000 +++ b/Objects/complexobject.c Fri Jan 12 01:21:14 1996 +0000 @@ -208,6 +208,18 @@ } } +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;
