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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
6331b638
Commit
6331b638
authored
Apr 10, 2013
by
nbruin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
explain difference between cdef and cpdef
parent
d632c550
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
docs/src/quickstart/cythonize.rst
docs/src/quickstart/cythonize.rst
+9
-6
No files found.
docs/src/quickstart/cythonize.rst
View file @
6331b638
...
@@ -94,13 +94,16 @@ object or if it is guaranteed that an exception will not be raised
...
@@ -94,13 +94,16 @@ object or if it is guaranteed that an exception will not be raised
within the function call.
within the function call.
A side-effect of cdef is that the function is no longer available from
A side-effect of cdef is that the function is no longer available from
Python-space, as Python wouldn't know how to call it. Using the
Python-space, as Python wouldn't know how to call it. It is also no
``cpdef`` keyword instead of cdef, a Python wrapper is also created,
longer possible to change ``f` at runtime.
so that the function is available both from Cython (fast, passing
typed values directly) and from Python (wrapping values in Python
objects).
Note also that it is no longer possible to change ``f`` at runtime.
Using the ``cpdef`` keyword instead of ``cdef``, a Python wrapper is also
created, so that the function is available both from Cython (fast, passing
typed values directly) and from Python (wrapping values in Python
objects). In fact, ``cpdef`` does not just provide a Python wrapper, it also
installs logic to allow the method to be overridden by python methods, even
when called from within cython. This does add a tiny overhead compared to ``cdef``
methods.
Speedup: 150 times over pure Python.
Speedup: 150 times over pure Python.
...
...
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