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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
5e1c1648
Commit
5e1c1648
authored
Jun 14, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put the pep 526 example in the examples directory for testing.
parent
5fadf79e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
19 deletions
+24
-19
docs/examples/tutorial/pure/pep_526.py
docs/examples/tutorial/pure/pep_526.py
+22
-0
docs/src/tutorial/pure.rst
docs/src/tutorial/pure.rst
+2
-19
No files found.
docs/examples/tutorial/pure/pep_526.py
0 → 100644
View file @
5e1c1648
import
cython
def
func
():
# Cython types are evaluated as for cdef declarations
x
:
cython
.
int
# cdef int x
y
:
cython
.
double
=
0.57721
# cdef double y = 0.57721
z
:
cython
.
float
=
0.57721
# cdef float z = 0.57721
# Python types shadow Cython types for compatibility reasons
a
:
float
=
0.54321
# cdef double a = 0.54321
b
:
int
=
5
# cdef object b = 5
c
:
long
=
6
# cdef object c = 6
pass
@
cython
.
cclass
class
A
:
a
:
cython
.
int
b
:
cython
.
int
def
__init__
(
self
,
b
=
0
):
self
.
a
=
3
self
.
b
=
b
docs/src/tutorial/pure.rst
View file @
5e1c1648
...
...
@@ -223,26 +223,9 @@ Static typing
Since version 0.27, Cython also supports the variable annotations defined
in `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_. This allows to
declare types of variables in a Python 3.6 compatible way as follows:
:
declare types of variables in a Python 3.6 compatible way as follows:
def func():
# Cython types are evaluated as for cdef declarations
x : cython.int # cdef int x
y : cython.double = 0.57721 # cdef double y = 0.57721
z : cython.float = 0.57721 # cdef float z = 0.57721
# Python types shadow Cython types for compatibility reasons
a : float = 0.54321 # cdef double a = 0.54321
b : int = 5 # cdef object b = 5
c : long = 6 # cdef object c = 6
@cython.cclass
class A:
a : cython.int
b : cython.int
def __init__(self, b=0):
self.a = 3
self.b = b
.. literalinclude:: ../../examples/tutorial/pure/pep_526.py
There is currently no way to express the visibility of object attributes.
...
...
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