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
83ab0e26
Commit
83ab0e26
authored
Jun 01, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.22.x'
parents
51971799
68e229b4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-1
tests/run/future_division.pyx
tests/run/future_division.pyx
+14
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
83ab0e26
...
@@ -10241,11 +10241,20 @@ class DivNode(NumBinopNode):
...
@@ -10241,11 +10241,20 @@ class DivNode(NumBinopNode):
except
Exception
,
e
:
except
Exception
,
e
:
self
.
compile_time_value_error
(
e
)
self
.
compile_time_value_error
(
e
)
def
analyse_operat
ion
(
self
,
env
):
def
_check_truedivis
ion
(
self
,
env
):
if
self
.
cdivision
or
env
.
directives
[
'cdivision'
]:
if
self
.
cdivision
or
env
.
directives
[
'cdivision'
]:
self
.
ctruedivision
=
False
self
.
ctruedivision
=
False
else
:
else
:
self
.
ctruedivision
=
self
.
truedivision
self
.
ctruedivision
=
self
.
truedivision
def
infer_type
(
self
,
env
):
self
.
_check_truedivision
(
env
)
return
self
.
result_type
(
self
.
operand1
.
infer_type
(
env
),
self
.
operand2
.
infer_type
(
env
))
def
analyse_operation
(
self
,
env
):
self
.
_check_truedivision
(
env
)
NumBinopNode
.
analyse_operation
(
self
,
env
)
NumBinopNode
.
analyse_operation
(
self
,
env
)
if
self
.
is_cpp_operation
():
if
self
.
is_cpp_operation
():
self
.
cdivision
=
True
self
.
cdivision
=
True
...
...
tests/run/future_division.pyx
View file @
83ab0e26
from
__future__
import
division
from
__future__
import
division
cimport
cython
def
doit
(
x
,
y
):
def
doit
(
x
,
y
):
"""
"""
>>> doit(1,2)
>>> doit(1,2)
...
@@ -115,3 +117,15 @@ def float_mix_rev(float a):
...
@@ -115,3 +117,15 @@ def float_mix_rev(float a):
(0.25, 0.0, 1.25, 1.0, 1.25, 1.0)
(0.25, 0.0, 1.25, 1.0, 1.25, 1.0)
"""
"""
return
1
/
a
,
1
//
a
,
5.0
/
a
,
5.0
//
a
,
5
/
a
,
5
//
a
return
1
/
a
,
1
//
a
,
5.0
/
a
,
5.0
//
a
,
5
/
a
,
5
//
a
def
infer_division_type
():
"""
>>> v = infer_division_type()
double
>>> v
8333333.25
"""
v
=
(
10000
**
2
-
1
)
/
12
print
(
cython
.
typeof
(
v
))
return
v
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