Commit ace34b34 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2352 from gabrieldemarmiesse/test_cdef_classes_5

Added tests for cdef_classes.rst. Part 5
parents bdcd42a9 93b94788
from sin_of_square cimport Function
cdef class WaveFunction(Function):
# Not available in Python-space:
cdef double offset
# Available in Python-space:
cdef public double freq
# Available in Python-space, but only for reading:
cdef readonly double scale
# Available in Python-space:
@property
def period(self):
return 1.0 / self.freq
@period.setter
def period(self, value):
self.freq = 1.0 / value
...@@ -105,18 +105,4 @@ Attributes in cdef classes behave differently from attributes in regular classes ...@@ -105,18 +105,4 @@ Attributes in cdef classes behave differently from attributes in regular classes
- Attributes are by default only accessible from Cython (typed access) - Attributes are by default only accessible from Cython (typed access)
- Properties can be declared to expose dynamic attributes to Python-space - Properties can be declared to expose dynamic attributes to Python-space
:: .. literalinclude:: ../../examples/tutorial/cdef_classes/wave_function.pyx
cdef class WaveFunction(Function):
# Not available in Python-space:
cdef double offset
# Available in Python-space:
cdef public double freq
# Available in Python-space:
@property
def period(self):
return 1.0 / self.freq
@period.setter
def period(self, value):
self.freq = 1.0 / value
<...>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment