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
f324eca3
Commit
f324eca3
authored
Mar 19, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent dict iter optimisation from striking at methods with unusual number of arguments
parent
d15a656c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+8
-1
tests/run/iterdict.pyx
tests/run/iterdict.pyx
+22
-0
No files found.
Cython/Compiler/Optimize.py
View file @
f324eca3
...
...
@@ -164,9 +164,16 @@ class IterationTransform(Visitor.VisitorTransform):
if
not
isinstance
(
iterator
,
ExprNodes
.
SimpleCallNode
):
return
node
if
iterator
.
args
is
None
:
arg_count
=
iterator
.
arg_tuple
and
len
(
iterator
.
arg_tuple
.
args
)
or
0
else
:
arg_count
=
len
(
iterator
.
args
)
if
arg_count
and
iterator
.
self
is
not
None
:
arg_count
-=
1
function
=
iterator
.
function
# dict iteration?
if
function
.
is_attribute
and
not
reversed
:
if
function
.
is_attribute
and
not
reversed
and
not
arg_count
:
base_obj
=
iterator
.
self
or
function
.
obj
method
=
function
.
attribute
...
...
tests/run/iterdict.pyx
View file @
f324eca3
...
...
@@ -174,6 +174,17 @@ def iterkeys(dict d):
l
.
sort
()
return
l
@
cython
.
test_fail_if_path_exists
(
"//WhileStatNode"
,
"//WhileStatNode//DictIterationNextNode"
)
def
iterkeys_argerror
(
dict
d
):
"""
>>> try: iterkeys_argerror(d)
... except TypeError: pass
"""
for
k
in
d
.
iterkeys
(
1
):
print
k
@
cython
.
test_assert_path_exists
(
"//WhileStatNode"
,
"//WhileStatNode//DictIterationNextNode"
)
...
...
@@ -203,6 +214,17 @@ def optimistic_iterkeys(d):
l
.
sort
()
return
l
@
cython
.
test_fail_if_path_exists
(
"//WhileStatNode"
,
"//WhileStatNode//DictIterationNextNode"
)
def
optimistic_iterkeys_argerror
(
d
):
"""
>>> try: optimistic_iterkeys_argerror(d)
... except TypeError: pass
"""
for
k
in
d
.
iterkeys
(
1
):
print
k
@
cython
.
test_assert_path_exists
(
"//WhileStatNode"
,
"//WhileStatNode//DictIterationNextNode"
)
...
...
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