bpo-30285: Optimize case-insensitive matching and searching#1482
Merged
serhiy-storchaka merged 6 commits intopython:masterfrom May 9, 2017
Merged
bpo-30285: Optimize case-insensitive matching and searching#1482serhiy-storchaka merged 6 commits intopython:masterfrom
serhiy-storchaka merged 6 commits intopython:masterfrom
Conversation
of regular expressions.
|
@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rhettinger, @Yhg1s and @niemeyer to be potential reviewers. |
rhettinger
reviewed
May 6, 2017
Lib/sre_compile.py
Outdated
| charmap[av] = 1 | ||
| elif op is RANGE: | ||
| r = range(av[0], av[1]+1) | ||
| r = r0 = range(av[0], av[1]+1) |
Member
Author
There was a problem hiding this comment.
At line 296.
if fixup and not hascased:
hascased = any(map(iscased, r0))
This intentionally moved after the loops that set bits in charmap because for large ranges like range(0x20000, 0x110000) it is better to get an IndexError earlier (the size of charmap is 0x100 or 0x10000) than burn CPU in long useless loop.
lisroach
reviewed
May 7, 2017
Lib/sre_compile.py
Outdated
| charmap = bytearray(256) | ||
| hascased = False | ||
| if fixup: | ||
| if flags & SRE_FLAG_UNICODE and not flags & SRE_FLAG_ASCII: |
Contributor
There was a problem hiding this comment.
Can the if/else statement from 264-267 be replaced with:
iscased = _get_iscased(flags)
?
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.
of regular expressions.