-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
Update to current fastest env setitem #4556
Conversation
Updated and re-ran benchmark tests for SubstitutionEnvironment.__setitem__. Added test for new (Python 3.0) string.isidentifier() method. That's actually exactly what we want, and it times out as the fastest method when combined with a membership test if the variable is already defined. Tweaked some comments about this performance consideration, and did other updates in bench/. Signed-off-by: Mats Wichmann <[email protected]>
Didn't notice that the changes for env.__setitem__ caused a quote mark to flip in the error output, failing one test (a back-quote went to a single regular quote). Updated the test, and snuck in the tools-performance-hack. Signed-off-by: Mats Wichmann <[email protected]>
bench/is_types.py
Outdated
@@ -51,7 +53,7 @@ def cache_type_e_is_Dict(e): | |||
|
|||
def cache_type_e_is_List(e): | |||
t = type(e) | |||
return t is list or isinstance(e, UserList) | |||
return t is list or isinstance(e, UserList or isinstance(e, deque)) |
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.
Is this right? or
inside the isinstance()?
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.
that got clumsy. I'll fix - think should be single isinstance
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.
yeah, it was supposed to look like the one a few lines later. pushed update.
Signed-off-by: Mats Wichmann <[email protected]>
Updated and re-ran benchmark tests for
SubstitutionEnvironment.__setitem__
. Added test for new (Python 3.0) string.isidentifier()
method. That's actually exactly what we want, and it times out as the fastest method when combined with a membership test if the variable is already defined.Tweaked some comments about this performance consideration, and did other updates in
bench/
.No doc impacts as there are no behavioral changes.
Contributor Checklist:
CHANGES.txt
(and read theREADME.rst
)