Commit 5c3fb00a authored by Robert Bradshaw's avatar Robert Bradshaw

Add note about type inference.

parent 9d2b6d78
...@@ -136,3 +136,13 @@ and for determining when to :ref:`release the GIL <nogil>`: ...@@ -136,3 +136,13 @@ and for determining when to :ref:`release the GIL <nogil>`:
in general, a ``nogil`` block may contain only "white" code. in general, a ``nogil`` block may contain only "white" code.
.. figure:: htmlreport.png .. figure:: htmlreport.png
Note that Cython deduces the type of local variables based on their assignments,
which can also cut down on the need to explicitly specify types everywhere.
For example, declaring ``dx`` to be of type double above is unnecessary,
as is declaring the type of ``s`` in the last version (where the return type
of ``f`` is known to be a C double.) A notable exception, however, is
*integer types used in arithmetic expressions*, as Cython is unable to ensure
that an overflow would not occur (and so falls back to ``object`` in case
Python's bignums are needed). To allow inference of C integer types, set the
``infer_types`` :ref:`directive <compiler-directives>` to ``True``.
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