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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
35b2180b
Commit
35b2180b
authored
Jul 20, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize refcounting for cdef assignments (like it was)
parent
53c0810f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
5 deletions
+22
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+3
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+13
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+1
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
35b2180b
...
@@ -809,6 +809,7 @@ class NameNode(AtomicExprNode):
...
@@ -809,6 +809,7 @@ class NameNode(AtomicExprNode):
# interned_cname string
# interned_cname string
is_name
=
1
is_name
=
1
skip_assignment_decref
=
False
def
create_analysed_rvalue
(
pos
,
env
,
entry
):
def
create_analysed_rvalue
(
pos
,
env
,
entry
):
node
=
NameNode
(
pos
)
node
=
NameNode
(
pos
)
...
@@ -1030,7 +1031,7 @@ class NameNode(AtomicExprNode):
...
@@ -1030,7 +1031,7 @@ class NameNode(AtomicExprNode):
rhs
.
generate_disposal_code
(
code
)
rhs
.
generate_disposal_code
(
code
)
else
:
else
:
if
self
.
type
.
is_pyobject
:
if
self
.
type
.
is_pyobject
and
not
self
.
skip_assignment_decref
:
#print "NameNode.generate_assignment_code: to", self.name ###
#print "NameNode.generate_assignment_code: to", self.name ###
#print "...from", rhs ###
#print "...from", rhs ###
#print "...LHS type", self.type, "ctype", self.ctype() ###
#print "...LHS type", self.type, "ctype", self.ctype() ###
...
...
Cython/Compiler/Main.py
View file @
35b2180b
...
@@ -359,7 +359,7 @@ def create_default_pipeline(context, options, result):
...
@@ -359,7 +359,7 @@ def create_default_pipeline(context, options, result):
from
ParseTreeTransforms
import
WithTransform
,
NormalizeTree
,
PostParse
from
ParseTreeTransforms
import
WithTransform
,
NormalizeTree
,
PostParse
from
ParseTreeTransforms
import
AnalyseDeclarationsTransform
,
AnalyseExpressionsTransform
from
ParseTreeTransforms
import
AnalyseDeclarationsTransform
,
AnalyseExpressionsTransform
from
ParseTreeTransforms
import
CreateClosureClasses
,
MarkClosureVisitor
,
DecoratorTransform
from
ParseTreeTransforms
import
CreateClosureClasses
,
MarkClosureVisitor
,
DecoratorTransform
from
Optimize
import
FlattenInListTransform
,
SwitchTransform
from
Optimize
import
FlattenInListTransform
,
SwitchTransform
,
OptimizeRefcounting
from
Buffer
import
BufferTransform
from
Buffer
import
BufferTransform
from
ModuleNode
import
check_c_classes
from
ModuleNode
import
check_c_classes
...
@@ -375,6 +375,7 @@ def create_default_pipeline(context, options, result):
...
@@ -375,6 +375,7 @@ def create_default_pipeline(context, options, result):
AnalyseExpressionsTransform
(
context
),
AnalyseExpressionsTransform
(
context
),
BufferTransform
(
context
),
BufferTransform
(
context
),
SwitchTransform
(),
SwitchTransform
(),
OptimizeRefcounting
(
context
),
# CreateClosureClasses(context),
# CreateClosureClasses(context),
create_generate_code
(
context
,
options
,
result
)
create_generate_code
(
context
,
options
,
result
)
]
]
...
...
Cython/Compiler/Nodes.py
View file @
35b2180b
...
@@ -2231,8 +2231,10 @@ class SingleAssignmentNode(AssignmentNode):
...
@@ -2231,8 +2231,10 @@ class SingleAssignmentNode(AssignmentNode):
#
#
# lhs ExprNode Left hand side
# lhs ExprNode Left hand side
# rhs ExprNode Right hand side
# rhs ExprNode Right hand side
# first bool Is this guaranteed the first assignment to lhs?
child_attrs
=
[
"lhs"
,
"rhs"
]
child_attrs
=
[
"lhs"
,
"rhs"
]
first
=
False
def
analyse_declarations
(
self
,
env
):
def
analyse_declarations
(
self
,
env
):
self
.
lhs
.
analyse_target_declaration
(
env
)
self
.
lhs
.
analyse_target_declaration
(
env
)
...
...
Cython/Compiler/Optimize.py
View file @
35b2180b
...
@@ -134,3 +134,16 @@ class FlattenInListTransform(Visitor.VisitorTransform):
...
@@ -134,3 +134,16 @@ class FlattenInListTransform(Visitor.VisitorTransform):
def
visit_Node
(
self
,
node
):
def
visit_Node
(
self
,
node
):
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
return
node
return
node
class
OptimizeRefcounting
(
Visitor
.
CythonTransform
):
def
visit_SingleAssignmentNode
(
self
,
node
):
if
node
.
first
:
lhs
=
node
.
lhs
if
isinstance
(
lhs
,
ExprNodes
.
NameNode
)
and
lhs
.
entry
.
type
.
is_pyobject
:
# Have variable initialized to 0 rather than None
lhs
.
entry
.
init_to_none
=
False
lhs
.
entry
.
init
=
0
# Set a flag in NameNode to skip the decref
lhs
.
skip_assignment_decref
=
True
return
node
Cython/Compiler/ParseTreeTransforms.py
View file @
35b2180b
...
@@ -138,7 +138,7 @@ class PostParse(CythonTransform):
...
@@ -138,7 +138,7 @@ class PostParse(CythonTransform):
raise
PostParseError
(
decl
.
pos
,
ERR_CDEF_INCLASS
)
raise
PostParseError
(
decl
.
pos
,
ERR_CDEF_INCLASS
)
stats
.
append
(
SingleAssignmentNode
(
node
.
pos
,
stats
.
append
(
SingleAssignmentNode
(
node
.
pos
,
lhs
=
NameNode
(
node
.
pos
,
name
=
decl
.
name
),
lhs
=
NameNode
(
node
.
pos
,
name
=
decl
.
name
),
rhs
=
decl
.
default
))
rhs
=
decl
.
default
,
first
=
True
))
decl
.
default
=
None
decl
.
default
=
None
return
stats
return
stats
...
...
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