8000 gh-117431: Adapt str.{start,end}swith to use the METH_FASTCALL calling convention by erlend-aasland · Pull Request #117466 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-117431: Adapt str.{start,end}swith to use the METH_FASTCALL calling convention #117466

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

Merged
merged 6 commits into from
Apr 3, 2024

Conversation

erlend-aasland
Copy link
Contributor
@erlend-aasland erlend-aasland commented Apr 2, 2024

@erlend-aasland
Copy link
Contributor Author

cc. faster-cpython/ideas#671

@erlend-aasland erlend-aasland changed the title Draft: adapt str.{start,end}swith to Argument Clinic gh-117431: Adapt str.{start,end}swith to use the METH_FASTCALL calling convention Apr 2, 2024
@erlend-aasland erlend-aasland marked this pull request as ready for review April 2, 2024 15:37
@erlend-aasland
8000 Copy link
Contributor Author
# main
$ ./python.exe -m timeit -s "s = 'abcdef'" "s.startswith('abc')"
5000000 loops, best of 5: 89.1 nsec per loop

# this PR
$ ./python.exe -m timeit -s "s = 'abcdef'" "s.startswith('abc')"
10000000 loops, best of 5: 26.4 nsec per loop

@erlend-aasland
Copy link
Contributor Author
erlend-aasland commented Apr 2, 2024

We'll also want to convert str.find and friend and finally get rid of the parsing helper in strlib. However, that is best left to a follow-up PR (#117468). I prefer small and incremental changes.

@erlend-aasland
Copy link
Contributor Author

Thanks for the review, @JelleZijlstra and @eendebakpt. I'll hold off merging for a day or two.

@erlend-aasland
Copy link
Contributor Author
erlend-aasland commented Apr 3, 2024

Well, with two core devs approving, I'll go ahead and merge. Thanks for the reviews.

@erlend-aasland erlend-aasland merged commit 444156e into python:main Apr 3, 2024
@erlend-aasland erlend-aasland deleted the perf/starwith branch April 3, 2024 07:11
8000
@vstinner
Copy link
Member
vstinner commented Apr 4, 2024

Nice optimization!

diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…inic (python#117466)

This change gives a significant speedup, as the METH_FASTCALL calling
convention is now used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0