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
58952319
Commit
58952319
authored
May 10, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved pure mode docs on function decorators
parent
348fff50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
docs/src/tutorial/pure.rst
docs/src/tutorial/pure.rst
+17
-6
No files found.
docs/src/tutorial/pure.rst
View file @
58952319
...
...
@@ -131,8 +131,8 @@ Types
There are numerous types built in to the cython module. One has all the
standard C types, namely ``char``, ``short``, ``int``, ``long``, ``longlong``
as well as their unsigned versions ``uchar``, ``ushort``, ``uint``, ``ulong``,
``ulonglong``.
One also has ``bint`` and ``Py_ssize_t``. For each type, on
e
has
pointer types ``p_int``, ``pp_int``, . . ., up to three levels deep in
``ulonglong``.
One also has ``bint`` and ``Py_ssize_t``. For each type, ther
e
are
pointer types ``p_int``, ``pp_int``, . . ., up to three levels deep in
interpreted mode, and infinitely deep in compiled mode. The Python types int,
long and bool are interpreted as C ``int``, ``long`` and ``bint``
respectively. Also, the python types ``list``, ``dict``, ``tuple``, . . . may
...
...
@@ -142,10 +142,21 @@ Pointer types may be constructed with ``cython.pointer(cython.int)``, and
arrays as ``cython.int[10]``. A limited attempt is made to emulate these more
complex types, but only so much can be done from the Python language.
Decorator
s
--------------------------------
Extension types and cdef function
s
--------------------------------
---
Use the ``@cython.cclass`` decorator to create a ``cdef class``.
Use the ``@cython.cfunc`` and ``@cython.ccall`` decorators for :keyword:`cdef`
and :keyword:`cpdef` functions (respectively).
Use the ``@cython.cfunc`` decorator for :keyword:`cdef` functions
and the ``@cython.ccall`` decorators for :keyword:`cpdef` functions
respectively. To declare the argument types, use the
``@cython.locals()`` decorator. For the return type, use
``@cython.returns(a_type)``.
Here is an example of a :keyword:`cdef` function::
@cython.cfunc
@cython.returns(cython.bint)
@cython.locals(a=cython.int, b=cython.int)
def c_compare(a,b):
return a == b
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