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
Gwenaël Samain
cython
Commits
b723ea4f
Commit
b723ea4f
authored
Nov 29, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor code optimisations
parent
a41594b4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
Cython/Compiler/ParseTreeTransforms.pxd
Cython/Compiler/ParseTreeTransforms.pxd
+4
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+8
-9
No files found.
Cython/Compiler/ParseTreeTransforms.pxd
View file @
b723ea4f
cimport
cython
from
Cython.Compiler.Visitor
cimport
(
CythonTransform
,
VisitorTransform
,
TreeVisitor
,
ScopeTrackingTransform
,
EnvTransform
)
...
...
@@ -12,6 +14,7 @@ cdef class SkipDeclarations: # (object):
cdef
class
NormalizeTree
(
CythonTransform
):
cdef
bint
is_in_statlist
cdef
bint
is_in_expr
cpdef
visit_StatNode
(
self
,
node
,
is_listcontainer
=*
)
cdef
class
PostParse
(
ScopeTrackingTransform
):
cdef
dict
specialattribute_handlers
...
...
@@ -21,6 +24,7 @@ cdef class PostParse(ScopeTrackingTransform):
#def eliminate_rhs_duplicates(list expr_list_list, list ref_node_sequence)
#def sort_common_subsequences(list items)
@
cython
.
locals
(
starred_targets
=
Py_ssize_t
,
lhs_size
=
Py_ssize_t
,
rhs_size
=
Py_ssize_t
)
cdef
flatten_parallel_assignments
(
list
input
,
list
output
)
cdef
map_starred_assignment
(
list
lhs_targets
,
list
starred_assignments
,
list
lhs_args
,
list
rhs_args
)
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
b723ea4f
import
cython
from
cython
import
set
cython
.
declare
(
copy
=
object
,
ModuleNode
=
object
,
TreeFragment
=
object
,
TemplateTransform
=
object
,
EncodedString
=
object
,
error
=
object
,
warning
=
object
,
PyrexTypes
=
object
,
Naming
=
object
)
...
...
@@ -301,7 +300,7 @@ def eliminate_rhs_duplicates(expr_list_list, ref_node_sequence):
and appends them to ref_node_sequence. The input list is modified
in-place.
"""
seen_nodes
=
set
()
seen_nodes
=
cython
.
set
()
ref_nodes
=
{}
def
find_duplicates
(
node
):
if
node
.
is_literal
or
node
.
is_name
:
...
...
@@ -572,16 +571,16 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
'operator.comma'
:
c_binop_constructor
(
','
),
}
special_methods
=
set
([
'declare'
,
'union'
,
'struct'
,
'typedef'
,
'sizeof'
,
'cast'
,
'pointer'
,
'compiled'
,
'NULL'
]
+
list
(
unop_method_nodes
.
keys
()
))
special_methods
=
cython
.
set
([
'declare'
,
'union'
,
'struct'
,
'typedef'
,
'sizeof'
,
'cast'
,
'pointer'
,
'compiled'
,
'NULL'
])
special_methods
.
update
(
unop_method_nodes
.
keys
(
))
def
__init__
(
self
,
context
,
compilation_directive_defaults
):
super
(
InterpretCompilerDirectives
,
self
).
__init__
(
context
)
self
.
compilation_directive_defaults
=
{}
for
key
,
value
in
compilation_directive_defaults
.
items
():
self
.
compilation_directive_defaults
[
unicode
(
key
)]
=
value
self
.
cython_module_names
=
set
()
self
.
cython_module_names
=
cython
.
set
()
self
.
directive_names
=
{}
def
check_directive_scope
(
self
,
pos
,
directive
,
scope
):
...
...
@@ -1023,7 +1022,7 @@ property NAME:
return
node
def
visit_ModuleNode
(
self
,
node
):
self
.
seen_vars_stack
.
append
(
set
())
self
.
seen_vars_stack
.
append
(
cython
.
set
())
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
self
.
visitchildren
(
node
)
self
.
seen_vars_stack
.
pop
()
...
...
@@ -1055,7 +1054,7 @@ property NAME:
return
node
def
visit_FuncDefNode
(
self
,
node
):
self
.
seen_vars_stack
.
append
(
set
())
self
.
seen_vars_stack
.
append
(
cython
.
set
())
lenv
=
node
.
local_scope
node
.
body
.
analyse_control_flow
(
lenv
)
# this will be totally refactored
node
.
declare_arguments
(
lenv
)
...
...
@@ -1077,7 +1076,7 @@ property NAME:
node
.
analyse_declarations
(
self
.
env_stack
[
-
1
])
# the node may or may not have a local scope
if
node
.
expr_scope
:
self
.
seen_vars_stack
.
append
(
set
(
self
.
seen_vars_stack
[
-
1
]))
self
.
seen_vars_stack
.
append
(
cython
.
set
(
self
.
seen_vars_stack
[
-
1
]))
self
.
env_stack
.
append
(
node
.
expr_scope
)
self
.
visitchildren
(
node
)
self
.
env_stack
.
pop
()
...
...
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