From 0b4207a2d9b416bd38bfde1254426fdf5f2b671a Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 9 Jul 2020 23:47:49 +0200 Subject: Use inline properties on the "PyComplex" builtin type declared in "cpython.complex" to provide C level access to the "real" and "imag" attributes (which Cython provides anyway for the 'undeclared' builtin type). --- Cython/Includes/cpython/complex.pxd | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Cython/Includes/cpython/complex.pxd b/Cython/Includes/cpython/complex.pxd index f5ba33957..3fa145008 100644 --- a/Cython/Includes/cpython/complex.pxd +++ b/Cython/Includes/cpython/complex.pxd @@ -14,9 +14,14 @@ cdef extern from "Python.h": ctypedef class __builtin__.complex [object PyComplexObject]: cdef Py_complex cval - # not making these available to keep them read-only: - #cdef double imag "cval.imag" - #cdef double real "cval.real" + + @property + cdef inline double real(self): + return self.cval.real + + @property + cdef inline double imag(self): + return self.cval.imag # PyTypeObject PyComplex_Type # This instance of PyTypeObject represents the Python complex -- cgit v1.2.1