-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-39028: Performance enhancement in keyword extraction #17576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ah, I missed that this code is used for EDIT: Both can make sense I guess, but for the clinic it is clearly interned I think? So another option is to have two versions here... |
Python/getargs.c
Outdated
if (kwname == key) { | ||
return kwstack[i]; | ||
} | ||
} | ||
/* ptr == ptr should normally find a match in since keyword keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is related to kwname == key
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change LGTM, but please move the comment before the pointers comparison or before the first loop.
Although this is almost dead code. It is used in just few sites generated by Argument Clinic and soon will not be used at all.
Ah, sorry, the use in |
ba65512
to
17561c2
Compare
Yeah, although it only will have remotely noticeable effects for >3 kwargs probably, which seems pretty rare in python. Anyway moved and tweaked the comment. |
Python/getargs.c
Outdated
} | ||
/* This function assumes the strings should be interned, so that this | ||
should only be reached on error, and the loop below will never | ||
find a match */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep the second loop, why we need to have both of find_keyword_interned
and find_keyword
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man, sorry, I do not think we do. I was trying around with it a bit, and apparently forgot to commit before pushing or something :/. fixed.
All keywords should first be checked for pointer identity. Only after that failed for all keywords (unlikely) should unicode equality be used. The original code would call unicode equality on any non-matching keyword argument. Meaning calling it often e.g. when a function has many kwargs but only the last one is provided.
17561c2
to
52562b9
Compare
LGTM. Would you create an NEWS entry? |
) All keywords should first be checked for pointer identity. Only after that failed for all keywords (unlikely) should unicode equality be used. The original code would call unicode equality on any non-matching keyword argument. Meaning calling it often e.g. when a function has many kwargs but only the last one is provided.
All keywords should first be checked for pointer identity. Only
after that failed for all keywords (unlikely) should unicode
equality be used.
The original code would call unicode equality on any non-matching
keyword argument. Meaning calling it often e.g. when a function
has many kwargs but only the last one is provided.
Unless I am missing something big, this seems like it was the original intention, and simple typo. It may make sense to backport?
I have to admit, I have not actually recompiled and timed this, I may do that tomorrow (but I have never had the need to compile python, so need to look up how).
https://bugs.python.org/issue39028