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
48af72b0
Commit
48af72b0
authored
May 15, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unused ComprehensionTransform class (which doesn't work anyway)
parent
30a1dbe7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
58 deletions
+1
-58
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+1
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+0
-56
No files found.
Cython/Compiler/Main.py
View file @
48af72b0
...
...
@@ -80,7 +80,7 @@ class Context(object):
from
ParseTreeTransforms
import
AnalyseDeclarationsTransform
,
AnalyseExpressionsTransform
from
ParseTreeTransforms
import
CreateClosureClasses
,
MarkClosureVisitor
,
DecoratorTransform
from
ParseTreeTransforms
import
InterpretCompilerDirectives
,
TransformBuiltinMethods
from
ParseTreeTransforms
import
ComprehensionTransform
,
AlignFunctionDefinitions
from
ParseTreeTransforms
import
AlignFunctionDefinitions
from
AutoDocTransforms
import
EmbedSignature
from
Optimize
import
FlattenInListTransform
,
SwitchTransform
,
IterationTransform
from
Optimize
import
FlattenBuiltinTypeCreation
,
ConstantFolding
,
FinalOptimizePhase
...
...
@@ -125,7 +125,6 @@ class Context(object):
AnalyseExpressionsTransform
(
self
),
FlattenBuiltinTypeCreation
(),
ConstantFolding
(),
# ComprehensionTransform(),
IterationTransform
(),
SwitchTransform
(),
FinalOptimizePhase
(
self
),
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
48af72b0
...
...
@@ -589,62 +589,6 @@ class WithTransform(CythonTransform, SkipDeclarations):
return
node
class
ComprehensionTransform
(
VisitorTransform
):
"""Prevent the target of list/set/dict comprehensions from leaking by
moving it into a temp variable. This mimics the behaviour of all
comprehensions in Py3 and of generator expressions in Py2.x.
This must run before the IterationTransform, which might replace
for-loops with while-loops. We only handle for-loops here.
"""
def
visit_ModuleNode
(
self
,
node
):
self
.
comprehension_targets
=
{}
self
.
visitchildren
(
node
)
return
node
visit_Node
=
VisitorTransform
.
recurse_to_children
def
visit_ComprehensionNode
(
self
,
node
):
if
type
(
node
.
loop
)
not
in
(
Nodes
.
ForInStatNode
,
Nodes
.
ForFromStatNode
):
# this should not happen!
self
.
visitchildren
(
node
)
return
node
outer_comprehension_targets
=
self
.
comprehension_targets
self
.
comprehension_targets
=
outer_comprehension_targets
.
copy
()
# find all NameNodes in the loop target
target_name_collector
=
NameNodeCollector
()
target_name_collector
.
visit
(
node
.
loop
.
target
)
targets
=
target_name_collector
.
name_nodes
# create a temp variable for each target name
temps
=
[]
for
target
in
targets
:
handle
=
TempHandle
(
target
.
type
)
temps
.
append
(
handle
)
self
.
comprehension_targets
[
target
.
entry
.
cname
]
=
handle
.
ref
(
node
.
pos
)
# replace name references in the loop code by their temp node
self
.
visitchildren
(
node
,
[
'loop'
])
loop
=
node
.
loop
if
type
(
loop
)
is
Nodes
.
ForFromStatNode
and
loop
.
target
.
type
.
is_numeric
:
loop
.
loopvar_node
=
loop
.
target
node
.
loop
=
TempsBlockNode
(
node
.
pos
,
body
=
node
.
loop
,
temps
=
temps
)
self
.
comprehension_targets
=
outer_comprehension_targets
return
node
def
visit_NameNode
(
self
,
node
):
if
node
.
entry
:
replacement
=
self
.
comprehension_targets
.
get
(
node
.
entry
.
cname
)
if
replacement
is
not
None
:
return
replacement
return
node
class
DecoratorTransform
(
CythonTransform
,
SkipDeclarations
):
def
visit_DefNode
(
self
,
func_node
):
...
...
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