]> granicus.if.org Git - python/commitdiff
Added PyComplex_AsCComplex
authorGuido van Rossum <guido@python.org>
Fri, 12 Jan 1996 01:21:14 +0000 (01:21 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 12 Jan 1996 01:21:14 +0000 (01:21 +0000)
Objects/complexobject.c

index 8299b0b733c42b75c13f31b464753cf4c01c9413..20eab1e1f6a253bd917b11ac355edcf494508e00 100644 (file)
@@ -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;