diff options
Diffstat (limited to 'docs/src/tutorial/pure.rst')
-rw-r--r-- | docs/src/tutorial/pure.rst | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/docs/src/tutorial/pure.rst b/docs/src/tutorial/pure.rst index a536f2b31..91a381d1a 100644 --- a/docs/src/tutorial/pure.rst +++ b/docs/src/tutorial/pure.rst @@ -29,6 +29,7 @@ In pure mode, you are more or less restricted to code that can be expressed beyond that can only be done in .pyx files with extended language syntax, because it depends on features of the Cython compiler. +.. _augmenting_pxd: Augmenting .pxd --------------- @@ -249,6 +250,8 @@ releasing or acquiring the GIL. The condition must be constant (at compile time) A common use case for conditionally acquiring and releasing the GIL are fused types that allow different GIL handling depending on the specific type (see :ref:`gil_conditional`). +.. py:module:: cython.cimports + cimports ^^^^^^^^ @@ -344,8 +347,7 @@ PEP-484 type annotations Python `type hints <https://www.python.org/dev/peps/pep-0484>`_ can be used to declare argument types, as shown in the -following example. To avoid conflicts with other kinds of annotation -usages, this can be disabled with the directive ``annotation_typing=False``. +following example: .. literalinclude:: ../../examples/tutorial/pure/annotations.py @@ -375,6 +377,18 @@ declare types of variables in a Python 3.6 compatible way as follows: There is currently no way to express the visibility of object attributes. +Disabling annotations +^^^^^^^^^^^^^^^^^^^^^ + +To avoid conflicts with other kinds of annotation +usages, Cython's use of annotations to specify types can be disabled with the +``annotation_typing`` :ref:`compiler directive<compiler-directives>`. From Cython 3 +you can use this as a decorator or a with statement, as shown in the following example: + +.. literalinclude:: ../../examples/tutorial/pure/disabled_annotations.py + + + ``typing`` Module ^^^^^^^^^^^^^^^^^ |