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
7553a7f1
Commit
7553a7f1
authored
Nov 12, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actualy use PyNumber_Inplace* operations.
parent
0c71ed61
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
22 deletions
+11
-22
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-15
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+3
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
7553a7f1
...
...
@@ -5407,7 +5407,7 @@ class BinopNode(ExprNode):
#print "BinopNode.generate_result_code:", self.operand1, self.operand2 ###
if
self
.
operand1
.
type
.
is_pyobject
:
function
=
self
.
py_operation_function
()
if
function
==
"PyNumber_Power"
:
if
self
.
operator
==
'**'
:
extra_args
=
", Py_None"
else
:
extra_args
=
""
...
...
@@ -5510,7 +5510,10 @@ class NumBinopNode(BinopNode):
BinopNode
.
is_py_operation_types
(
self
,
type1
,
type2
))
def
py_operation_function
(
self
):
return
self
.
py_functions
[
self
.
operator
]
fuction
=
self
.
py_functions
[
self
.
operator
]
if
self
.
inplace
:
fuction
=
fuction
.
replace
(
'PyNumber_'
,
'PyNumber_InPlace'
)
return
fuction
py_functions
=
{
"|"
:
"PyNumber_Or"
,
...
...
@@ -5527,7 +5530,6 @@ class NumBinopNode(BinopNode):
"**"
:
"PyNumber_Power"
}
class
IntBinopNode
(
NumBinopNode
):
# Binary operation taking integer arguments.
...
...
@@ -6642,13 +6644,14 @@ binop_node_classes = {
"**"
:
PowNode
}
def
binop_node
(
pos
,
operator
,
operand1
,
operand2
):
def
binop_node
(
pos
,
operator
,
operand1
,
operand2
,
inplace
=
False
):
# Construct binop node of appropriate class for
# given operator.
return
binop_node_classes
[
operator
](
pos
,
operator
=
operator
,
operand1
=
operand1
,
operand2
=
operand2
)
operand2
=
operand2
,
inplace
=
inplace
)
#-------------------------------------------------------------------
#
...
...
Cython/Compiler/Nodes.py
View file @
7553a7f1
...
...
@@ -3552,21 +3552,6 @@ class InPlaceAssignmentNode(AssignmentNode):
self
.
rhs
.
generate_disposal_code
(
code
)
self
.
rhs
.
free_temps
(
code
)
py_functions
=
{
"|"
:
"PyNumber_InPlaceOr"
,
"^"
:
"PyNumber_InPlaceXor"
,
"&"
:
"PyNumber_InPlaceAnd"
,
"+"
:
"PyNumber_InPlaceAdd"
,
"-"
:
"PyNumber_InPlaceSubtract"
,
"*"
:
"PyNumber_InPlaceMultiply"
,
"/"
:
"__Pyx_PyNumber_InPlaceDivide"
,
"%"
:
"PyNumber_InPlaceRemainder"
,
"<<"
:
"PyNumber_InPlaceLshift"
,
">>"
:
"PyNumber_InPlaceRshift"
,
"**"
:
"PyNumber_InPlacePower"
,
"//"
:
"PyNumber_InPlaceFloorDivide"
,
}
def
annotate
(
self
,
code
):
self
.
lhs
.
annotate
(
code
)
self
.
rhs
.
annotate
(
code
)
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
7553a7f1
...
...
@@ -1243,8 +1243,9 @@ class ExpandInplaceOperators(CythonTransform):
binop
=
binop_node
(
node
.
pos
,
operator
=
node
.
operator
,
operand1
=
dup
,
operand2
=
rhs
)
node
=
SingleAssignmentNode
(
node
.
pos
,
lhs
=
lhs
,
rhs
=
binop
)
#, inplace=True)
operand2
=
rhs
,
inplace
=
True
)
node
=
SingleAssignmentNode
(
node
.
pos
,
lhs
=
lhs
,
rhs
=
binop
)
# Use LetRefNode to avoid side effects.
let_ref_nodes
.
reverse
()
for
t
in
let_ref_nodes
:
...
...
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