summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-07-09 23:47:49 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-07-09 23:47:49 +0200
commit0b4207a2d9b416bd38bfde1254426fdf5f2b671a (patch)
tree63240ed45c4398460f1f7bd6fc97e76e047a6e80
parent187992df77d6a01410a1e30d2071ad3da51f484f (diff)
downloadcython-0b4207a2d9b416bd38bfde1254426fdf5f2b671a.tar.gz
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).
-rw-r--r--Cython/Includes/cpython/complex.pxd11
1 files 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