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
e92a6012
Commit
e92a6012
authored
Sep 22, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Visitor dispatch optimization
parent
b0b1ba40
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
Cython/Compiler/Visitor.py
Cython/Compiler/Visitor.py
+3
-4
No files found.
Cython/Compiler/Visitor.py
View file @
e92a6012
...
...
@@ -16,12 +16,11 @@ class BasicVisitor(object):
self
.
dispatch_table
=
{}
def
visit
(
self
,
obj
):
pattern
=
"visit_%s"
cls
=
obj
.
__class__
mname
=
pattern
%
cls
.
__name__
m
=
self
.
dispatch_table
.
get
(
mname
)
m
=
self
.
dispatch_table
.
get
(
cls
.
__name__
)
if
m
is
None
:
# Must resolve, try entire hierarchy
pattern
=
"visit_%s"
mro
=
inspect
.
getmro
(
cls
)
for
cls
in
mro
:
m
=
getattr
(
self
,
pattern
%
cls
.
__name__
,
None
)
...
...
@@ -33,7 +32,7 @@ class BasicVisitor(object):
print
self
.
access_path
[
-
1
][
0
].
pos
print
self
.
access_path
[
-
1
][
0
].
__dict__
raise
RuntimeError
(
"Visitor does not accept object: %s"
%
obj
)
self
.
dispatch_table
[
mname
]
=
m
self
.
dispatch_table
[
cls
.
__name__
]
=
m
return
m
(
obj
)
class
TreeVisitor
(
BasicVisitor
):
...
...
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