Home | History | Annotate | Download | only in cpython
      1 
      2 cdef extern from "Python.h":
      3 
      4     ctypedef struct Py_complex:
      5         double imag
      6         double real
      7 
      8     ############################################################################
      9     # 7.2.5.2 Complex Numbers as Python Objects
     10     ############################################################################
     11 
     12     # PyComplexObject
     13     # This subtype of PyObject represents a Python complex number object.
     14 
     15     ctypedef class __builtin__.complex [object PyComplexObject]:
     16         cdef Py_complex cval
     17         # not making these available to keep them read-only:
     18         #cdef double imag "cval.imag"
     19         #cdef double real "cval.real"
     20 
     21     # PyTypeObject PyComplex_Type
     22     # This instance of PyTypeObject represents the Python complex
     23     # number type. It is the same object as complex and
     24     # types.ComplexType.
     25 
     26     bint PyComplex_Check(object p)
     27     # Return true if its argument is a PyComplexObject or a subtype of
     28     # PyComplexObject.
     29 
     30     bint PyComplex_CheckExact(object p)
     31     # Return true if its argument is a PyComplexObject, but not a subtype of PyComplexObject.
     32 
     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.
     36 
     37     object PyComplex_FromDoubles(double real, double imag)
     38     # Return value: New reference.
     39     # Return a new PyComplexObject object from real and imag.
     40 
     41     double PyComplex_RealAsDouble(object op) except? -1
     42     # Return the real part of op as a C double.
     43 
     44     double PyComplex_ImagAsDouble(object op) except? -1
     45     # Return the imaginary part of op as a C double.
     46 
     47     Py_complex PyComplex_AsCComplex(object op)
     48     # Return the Py_complex value of the complex number op.
     49     #
     50     # Returns (-1+0i) in case of an error
     51