Commit 5341a2f6 authored by Dr Alex Meakins's avatar Dr Alex Meakins Committed by GitHub

Added basic ctuple documentation.

parent 98bef7ce
......@@ -119,6 +119,9 @@ You can read more about them in :ref:`extension-types`.
Types
-----
Types
-----
Cython uses the normal C syntax for C types, including pointers. It provides
all the standard C types, namely ``char``, ``short``, ``int``, ``long``,
``long long`` as well as their ``unsigned`` versions, e.g. ``unsigned int``.
......@@ -148,6 +151,13 @@ typing and instead interpreted as C ``int``, ``long``, and ``float``
respectively, as statically typing variables with these Python
types has zero advantages.
Cython provides an accelerated and typed equivalent of a Python tuple.
A ``ctuple`` is assembled from any valid C types, for example::
cdef (double, int) bar
They can be used like a Python tuple, including as function arguments and as return types.
While these C types can be vastly faster, they have C semantics.
Specifically, the integer types overflow
and the C ``float`` type only has 32 bits of precision
......@@ -208,6 +218,11 @@ using normal C declaration syntax. For example,::
cdef int eggs(unsigned long l, float f):
...
''ctuples'' may also be used::
cdef (int, float) chips((long, long, double) t):
...
When a parameter of a Python function is declared to have a C data type, it is
passed in as a Python object and automatically converted to a C value, if
possible. In other words, the definition of ``spam`` above is equivalent to
......
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