diff options
author | scoder <stefan_ml@behnel.de> | 2018-08-24 07:53:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-24 07:53:38 +0200 |
commit | b1f7ef1174df5a3c8763540ddedf3730fc3e1342 (patch) | |
tree | e80b408cca7a398f3bd173e279f9f84b54768c5d | |
parent | d963bdffc900155b2e59b089815358c9c0d5ae7b (diff) | |
parent | 6437de446078158bc3f1e2a51623e601babf882b (diff) | |
download | cython-b1f7ef1174df5a3c8763540ddedf3730fc3e1342.tar.gz |
Merge pull request #2575 from CnlPepper/master
Added basic ctuple documentation.
-rw-r--r-- | docs/src/userguide/language_basics.rst | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/src/userguide/language_basics.rst b/docs/src/userguide/language_basics.rst index be5134de7..b5746e318 100644 --- a/docs/src/userguide/language_basics.rst +++ b/docs/src/userguide/language_basics.rst @@ -148,6 +148,14 @@ 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, the ``ctuple``. +A ``ctuple`` is assembled from any valid C types. For example:: + + cdef (double, int) bar + +They compile down to C-structures and can be used as efficient alternatives to +Python tuples. + 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 +216,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 |