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
Boxiang Sun
cython
Commits
9c4d28fb
Commit
9c4d28fb
authored
Jun 15, 2018
by
scoder
Committed by
GitHub
Jun 15, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2341 from gabrieldemarmiesse/pure_python_mode_7
Adding tests for "pure python mode" part 7
parents
79256a34
5e1c1648
Changes
2
Hide 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 @
9c4d28fb
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 @
9c4d28fb
...
...
@@ -185,26 +185,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