Merge docs repo
[cython.git] / docs / src / tutorial / caveats.rst
1 Caveats
2 =======
3
4 Since Cython mixes C and Python semantics, some things may be a bit
5 surprising or unintuitive. Work always goes on to make Cython more natural
6 for Python users, so this list may change in the future.
7
8  - ``10**-2 == 0``, instead of ``0.01`` like in Python.
9  - Given two typed ``int`` variables ``a`` and ``b``, ``a % b`` has the
10    same sign as the second argument (following Python semantics) rather then
11    having the same sign as the first (as in C).  The C behavior can be 
12    obtained, at some speed gain, by enabling the division directive. 
13    (Versions prior to Cython 0.12. always followed C semantics.)
14  - Care is needed with unsigned types. ``cdef unsigned n = 10;
15    print(range(-n, n))`` will print an empty list, since ``-n`` wraps
16    around to a large positive integer prior to being passed to the
17    ``range`` function.
18  - Python's ``float`` type actually wraps C ``double`` values, and 
19    Python's ``int`` type wraps C ``long`` values.