2 cdef extern from "Python.h":
4 ctypedef struct Py_complex:
8 ############################################################################
9 # 7.2.5.2 Complex Numbers as Python Objects
10 ############################################################################
13 # This subtype of PyObject represents a Python complex number object.
15 ctypedef class __builtin__.complex [object PyComplexObject]:
17 # not making these available to keep them read-only:
18 #cdef double imag "cval.imag"
19 #cdef double real "cval.real"
21 # PyTypeObject PyComplex_Type
22 # This instance of PyTypeObject represents the Python complex
23 # number type. It is the same object as complex and
26 bint PyComplex_Check(object p)
27 # Return true if its argument is a PyComplexObject or a subtype of
30 bint PyComplex_CheckExact(object p)
31 # Return true if its argument is a PyComplexObject, but not a subtype of PyComplexObject.
33 object PyComplex_FromCComplex(Py_complex v)
34 # Return value: New reference.
35 # Create a new Python complex number object from a C Py_complex value.
37 object PyComplex_FromDoubles(double real, double imag)
38 # Return value: New reference.
39 # Return a new PyComplexObject object from real and imag.
41 double PyComplex_RealAsDouble(object op) except? -1
42 # Return the real part of op as a C double.
44 double PyComplex_ImagAsDouble(object op) except? -1
45 # Return the imaginary part of op as a C double.
47 Py_complex PyComplex_AsCComplex(object op)
48 # Return the Py_complex value of the complex number op.
50 # Returns (-1+0i) in case of an error