pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/pull/148733

ps://github.githubassets.com/assets/actions-0e714a98ea09295a.css" /> gh-148729: use memchr in SRE prefix scan by haampie · Pull Request #148733 · python/cpython · GitHub
Skip to content

gh-148729: use memchr in SRE prefix scan#148733

Open
haampie wants to merge 2 commits intopython:mainfrom
haampie:hs/feature/re-search-memchr
Open

gh-148729: use memchr in SRE prefix scan#148733
haampie wants to merge 2 commits intopython:mainfrom
haampie:hs/feature/re-search-memchr

Conversation

@haampie
Copy link
Copy Markdown
Contributor

@haampie haampie commented Apr 18, 2026

For USC1 strings use memchr instead of the equivalent
hand-written while loop.

This ensures that re.search is typically vectorized through libc for
regexes starting with a LITERAL. In the no-match case this means 16 or
32 bytes per iteration instead of a single byte (with PGO it does unroll,
but that seems to be all).

Comment thread Modules/_sre/sre_lib.h Outdated
Comment thread Modules/_sre/sre_lib.h Outdated
For single byte characters use `memchr` instead of the equivalent
hand-written while loop.

This ensures that `re.search` is typically vectorized through libc for
regexes starting with a `LITERAL`. In the no-match case this means 16 or
32 bytes per iterations instead of a single byte (ok, it was unrolled,
but not auto-vectorized).

Signed-off-by: Harmen Stoppels <harmenstoppels@gmail.com>
@haampie haampie force-pushed the hs/feature/re-search-memchr branch from f896a82 to e488932 Compare April 18, 2026 22:04
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in Library.

Signed-off-by: Harmen Stoppels <harmenstoppels@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy