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
1e0ed76a
Commit
1e0ed76a
authored
May 03, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent 2**N optimisation from breaking 2.0**N
parent
52099c3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
0 deletions
+4
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-0
tests/run/powop.pyx
tests/run/powop.pyx
+3
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
1e0ed76a
...
...
@@ -9555,6 +9555,7 @@ class PowNode(NumBinopNode):
def
py_operation_function
(
self
,
code
):
if
(
self
.
type
.
is_pyobject
and
self
.
operand1
.
constant_result
==
2
and
isinstance
(
self
.
operand1
.
constant_result
,
(
int
,
long
))
and
self
.
operand2
.
type
is
py_object_type
):
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
'PyNumberPow2'
,
'Optimize.c'
))
if
self
.
inplace
:
...
...
tests/run/powop.pyx
View file @
1e0ed76a
...
...
@@ -91,4 +91,7 @@ def optimised_pow2(n):
Traceback (most recent call last):
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'str'
"""
if
isinstance
(
n
,
(
int
,
long
))
and
0
<=
n
<
1000
:
assert
isinstance
(
2.0
**
n
,
float
),
'float %s'
%
n
assert
isinstance
(
2
**
n
,
(
int
,
long
)),
'int %s'
%
n
return
2
**
n
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