Commit 58952319 authored by Stefan Behnel's avatar Stefan Behnel

improved pure mode docs on function decorators

parent 348fff50
......@@ -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, one
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, there
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.
Decorators
--------------------------------
Extension types and cdef functions
-----------------------------------
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment