bpo-31671: re.compile() cache checks flags type#3867
Closed
vstinner wants to merge 3 commits intopython:masterfrom
vstinner:re_compile_flags_type
Closed
bpo-31671: re.compile() cache checks flags type#3867vstinner wants to merge 3 commits intopython:masterfrom vstinner:re_compile_flags_type
vstinner wants to merge 3 commits intopython:masterfrom
vstinner:re_compile_flags_type
Conversation
Make sure that float flags are rejected even if the cache has an entry with equal flags but flags of a different type.
vstinner
commented
Oct 3, 2017
| _MAXCACHE = 512 | ||
| def _compile(pattern, flags): | ||
| # internal: compile pattern | ||
| cache_key = (type(pattern), pattern, type(flags), flags) |
Member
Author
There was a problem hiding this comment.
Putting type(flags) in the cache key prevents to merge flags=2 with flags=re.IGNORECASE.
I suggest to first focus on correctness. I let @methane handles the performance part with his PR #3862 :-)
But I propose to backport my fix to 2.7 and 3.6 without the optimization, so a minor performance regression for Python 3.6.
Member
Author
|
I abandon my change for these reasons: https://bugs.python.org/issue31671#msg303753 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make sure that float flags are rejected even if the cache has an
entry with equal flags but flags of a different type.
https://bugs.python.org/issue31671