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
7560a9e7
Commit
7560a9e7
authored
Jun 13, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved a code snippet from cdef_classes.rst to the examples directory to add it to the tests.
parent
5fadf79e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
docs/examples/tutorial/cdef_classes/math_function.py
docs/examples/tutorial/cdef_classes/math_function.py
+7
-0
docs/src/tutorial/cdef_classes.rst
docs/src/tutorial/cdef_classes.rst
+2
-8
No files found.
docs/examples/tutorial/cdef_classes/math_function.py
0 → 100644
View file @
7560a9e7
class
MathFunction
(
object
):
def
__init__
(
self
,
name
,
operator
):
self
.
name
=
name
self
.
operator
=
operator
def
__call__
(
self
,
*
operands
):
return
self
.
operator
(
*
operands
)
docs/src/tutorial/cdef_classes.rst
View file @
7560a9e7
...
...
@@ -2,15 +2,9 @@ Extension types (aka. cdef classes)
===================================
To support object-oriented programming, Cython supports writing normal
Python classes exactly as in Python:
:
Python classes exactly as in Python:
class MathFunction(object):
def __init__(self, name, operator):
self.name = name
self.operator = operator
def __call__(self, *operands):
return self.operator(*operands)
.. literalinclude:: ../../examples/tutorial/cdef_classes/math_function.py
Based on what Python calls a "built-in type", however, Cython supports
a second kind of class: *extension types*, sometimes referred to as
...
...
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