Commit 59b13ab0 authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Put two examples of cython.declare in the examples directory.

parent 5fadf79e
import cython
x = cython.declare(cython.int) # cdef int x
y = cython.declare(cython.double, 0.57721) # cdef double y = 0.57721
import cython
cython.declare(x=cython.int, y=cython.double) # cdef int x; cdef double y
...@@ -159,14 +159,13 @@ Static typing ...@@ -159,14 +159,13 @@ Static typing
* ``cython.declare`` declares a typed variable in the current scope, which can be * ``cython.declare`` declares a typed variable in the current scope, which can be
used in place of the :samp:`cdef type var [= value]` construct. This has two forms, used in place of the :samp:`cdef type var [= value]` construct. This has two forms,
the first as an assignment (useful as it creates a declaration in interpreted the first as an assignment (useful as it creates a declaration in interpreted
mode as well):: mode as well):
x = cython.declare(cython.int) # cdef int x .. literalinclude:: ../../examples/tutorial/pure/cython_declare.py
y = cython.declare(cython.double, 0.57721) # cdef double y = 0.57721
and the second mode as a simple function call:: and the second mode as a simple function call:
cython.declare(x=cython.int, y=cython.double) # cdef int x; cdef double y .. literalinclude:: ../../examples/tutorial/pure/cython_declare2.py
It can also be used to type class constructors:: It can also be used to type class constructors::
......
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