Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
59b13ab0
Commit
59b13ab0
authored
Jun 14, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put two examples of cython.declare in the examples directory.
parent
5fadf79e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
docs/examples/tutorial/pure/cython_declare.py
docs/examples/tutorial/pure/cython_declare.py
+4
-0
docs/examples/tutorial/pure/cython_declare2.py
docs/examples/tutorial/pure/cython_declare2.py
+3
-0
docs/src/tutorial/pure.rst
docs/src/tutorial/pure.rst
+4
-5
No files found.
docs/examples/tutorial/pure/cython_declare.py
0 → 100644
View file @
59b13ab0
import
cython
x
=
cython
.
declare
(
cython
.
int
)
# cdef int x
y
=
cython
.
declare
(
cython
.
double
,
0.57721
)
# cdef double y = 0.57721
docs/examples/tutorial/pure/cython_declare2.py
0 → 100644
View file @
59b13ab0
import
cython
cython
.
declare
(
x
=
cython
.
int
,
y
=
cython
.
double
)
# cdef int x; cdef double y
docs/src/tutorial/pure.rst
View file @
59b13ab0
...
...
@@ -159,14 +159,13 @@ Static typing
* ``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,
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
y = cython.declare(cython.double, 0.57721) # cdef double y = 0.57721
.. literalinclude:: ../../examples/tutorial/pure/cython_declare.py
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.p
y
It can also be used to type class constructors::
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment