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
Gwenaël Samain
cython
Commits
6e0e4e11
Commit
6e0e4e11
authored
Mar 20, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable true division for language_level=3
parent
0bcc3c34
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+2
-2
tests/run/cython3.pyx
tests/run/cython3.pyx
+33
-0
No files found.
CHANGES.rst
View file @
6e0e4e11
...
...
@@ -20,6 +20,9 @@ Features added
Bugs fixed
----------
* Language level 3 did not enable true division (a.k.a. float division) for
integer operands.
* Runtime reported file paths of source files (e.g for profiling and tracing)
are now relative to the build root directory instead of the main source file.
...
...
Cython/Compiler/Main.py
View file @
6e0e4e11
...
...
@@ -89,8 +89,8 @@ class Context(object):
def
set_language_level
(
self
,
level
):
self
.
language_level
=
level
if
level
>=
3
:
from
.Future
import
print_function
,
unicode_literals
,
absolute_import
self
.
future_directives
.
update
([
print_function
,
unicode_literals
,
absolute_import
])
from
.Future
import
print_function
,
unicode_literals
,
absolute_import
,
division
self
.
future_directives
.
update
([
print_function
,
unicode_literals
,
absolute_import
,
division
])
self
.
modules
[
'builtins'
]
=
self
.
modules
[
'__builtin__'
]
# pipeline creation functions can now be found in Pipeline.py
...
...
tests/run/cython3.pyx
View file @
6e0e4e11
...
...
@@ -27,6 +27,39 @@ def locals_function(a, b=2):
return
locals
()
### true division
def
truediv
(
x
):
"""
>>> truediv(4)
2.0
>>> truediv(3)
1.5
"""
return
x
/
2
def
truediv_int
(
int
x
):
"""
>>> truediv_int(4)
2.0
>>> truediv_int(3)
1.5
"""
return
x
/
2
@
cython
.
cdivision
(
True
)
def
cdiv_int
(
int
x
):
"""
>>> cdiv_int(4)
2
>>> cdiv_int(3)
1
"""
return
x
/
2
### module level except-as tests
exc
=
[
None
]
...
...
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