Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
cython
Commits
8d73ea74
Commit
8d73ea74
authored
15 years ago
by
Stefan Behnel
Browse files
Options
Download
Email Patches
Plain Diff
safe a few cycles (~4%) when calling 'in' on dicts
parent
82d6bc7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
8 deletions
+25
-8
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+25
-8
No files found.
Cython/Compiler/ExprNodes.py
View file @
8d73ea74
...
...
@@ -4827,14 +4827,31 @@ class CmpNode(object):
if
'not'
in
op
:
negation
=
"!"
else
:
negation
=
""
if
op
==
'in'
or
op
==
'not_in'
:
code
.
putln
(
"%s = %s(%sPySequence_Contains(%s, %s)); %s"
%
(
result_code
,
coerce_result
,
negation
,
operand2
.
py_result
(),
operand1
.
py_result
(),
code
.
error_goto_if_neg
(
result_code
,
self
.
pos
)))
if
operand2
.
type
is
dict_type
:
code
.
globalstate
.
use_utility_code
(
raise_none_iter_error_utility_code
)
code
.
putln
(
"if (unlikely(%s == Py_None)) {"
%
operand2
.
py_result
())
code
.
putln
(
"__Pyx_RaiseNoneNotIterableError(); %s"
%
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"} else {"
)
code
.
putln
(
"%s = %s(%sPyDict_Contains(%s, %s)); %s"
%
(
result_code
,
coerce_result
,
negation
,
operand2
.
py_result
(),
operand1
.
py_result
(),
code
.
error_goto_if_neg
(
result_code
,
self
.
pos
)))
code
.
putln
(
"}"
)
else
:
code
.
putln
(
"%s = %s(%sPySequence_Contains(%s, %s)); %s"
%
(
result_code
,
coerce_result
,
negation
,
operand2
.
py_result
(),
operand1
.
py_result
(),
code
.
error_goto_if_neg
(
result_code
,
self
.
pos
)))
elif
(
operand1
.
type
.
is_pyobject
and
op
not
in
(
'is'
,
'is_not'
)):
code
.
putln
(
"%s = PyObject_RichCompare(%s, %s, %s); %s"
%
(
...
...
This diff is collapsed.
Click to expand it.
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