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
68e229b4
Commit
68e229b4
authored
Jun 01, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix type inference for C true division
parent
6344f0b0
Changes
2
Hide 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 @
68e229b4
...
...
@@ -9780,11 +9780,20 @@ class DivNode(NumBinopNode):
except
Exception
,
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'
]:
self
.
ctruedivision
=
False
else
:
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
)
if
self
.
is_cpp_operation
():
self
.
cdivision
=
True
...
...
tests/run/future_division.pyx
View file @
68e229b4
from
__future__
import
division
cimport
cython
def
doit
(
x
,
y
):
"""
>>> doit(1,2)
...
...
@@ -81,3 +83,15 @@ def float_mix_rev(float a):
(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
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