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
6edf0ef3
Commit
6edf0ef3
authored
Jun 12, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
16e9de64
f3f00195
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
16 deletions
+37
-16
docs/src/reference/extension_types.rst
docs/src/reference/extension_types.rst
+2
-2
docs/src/tutorial/cdef_classes.rst
docs/src/tutorial/cdef_classes.rst
+6
-5
docs/src/userguide/extension_types.rst
docs/src/userguide/extension_types.rst
+29
-9
No files found.
docs/src/reference/extension_types.rst
View file @
6edf0ef3
...
...
@@ -81,7 +81,7 @@ Methods
Properties
==========
* Cython provides a special syntax::
* Cython provides a special
(deprecated)
syntax::
cdef class Spam:
...
...
@@ -120,7 +120,7 @@ Properties
def __cinit__(self):
self.cheeses = []
property cheese:
property cheese:
# note that this syntax is deprecated
def __get__(self):
return "We don't have: %s" % self.cheeses
...
...
docs/src/tutorial/cdef_classes.rst
View file @
6edf0ef3
...
...
@@ -138,9 +138,10 @@ Attributes in cdef classes behave differently from attributes in regular classes
# Available in Python-space:
cdef public double freq
# Available in Python-space:
property period:
def __get__
(self):
@property
def period
(self):
return 1.0 / self.freq
def __set__(self, value):
@period.setter
def period(self, value):
self.freq = 1.0 / value
<...>
docs/src/userguide/extension_types.rst
View file @
6edf0ef3
...
...
@@ -223,7 +223,26 @@ extension types.
Properties
============
There is a special syntax for defining properties in an extension class::
You can declare properties in an extension class using the same syntax as in ordinary Python code::
cdef class Spam:
@property
def cheese(self):
# This is called when the property is read.
...
@cheese.setter
def cheese(self, value):
# This is called when the property is written.
...
@cheese.deleter
def cheese(self):
# This is called when the property is deleted.
There is also a special (deprecated) legacy syntax for defining properties in an extension class::
cdef class Spam:
...
...
@@ -259,15 +278,16 @@ when it is deleted.::
def __cinit__(self):
self.cheeses = []
property cheese:
def __get__(self):
@property
def cheese(self):
return "We don't have: %s" % self.cheeses
def __set__(self, value):
@cheese.setter
def cheese(self):
self.cheeses.append(value)
def __del__(self):
@cheese.deleter
def cheese(self):
del self.cheeses[:]
# Test input
...
...
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