Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
ace34b34
Commit
ace34b34
authored
Jun 15, 2018
by
scoder
Committed by
GitHub
Jun 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2352 from gabrieldemarmiesse/test_cdef_classes_5
Added tests for cdef_classes.rst. Part 5
parents
bdcd42a9
93b94788
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
15 deletions
+22
-15
docs/examples/tutorial/cdef_classes/wave_function.pyx
docs/examples/tutorial/cdef_classes/wave_function.pyx
+21
-0
docs/src/tutorial/cdef_classes.rst
docs/src/tutorial/cdef_classes.rst
+1
-15
No files found.
docs/examples/tutorial/cdef_classes/wave_function.pyx
0 → 100644
View file @
ace34b34
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
docs/src/tutorial/cdef_classes.rst
View file @
ace34b34
...
...
@@ -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)
- Properties can be declared to expose dynamic attributes to Python-space
::
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
<...>
.. literalinclude:: ../../examples/tutorial/cdef_classes/wave_function.pyx
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment