You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve performance of startswith, endswith, count, *find, and *index methods for str, bytes and bytearray #117431
changed the title [-]Improve performance of startswith and endswith methods for str and bytes[/-][+]Improve performance of startswith, endswith, count, *find, and *index methods for str, bytes and bytearray[/+]on Apr 3, 2024
Conversion of bytes/bytearray find() and friends1 is not straight-forward: the first argument can be either a buffer or an index in the range [0,255]. The code is shared between bytes and bytearray2. My first thought would be to create a custom Argument Clinic converter3, but we'd want that also to be shared between bytes and bytearray.
Activity
eendebakpt commentedon Apr 2, 2024
gh-117431: Adapt str.startswith and str.endswith to Argument Clinic (#…
[-]Improve performance of startswith and endswith methods for str and bytes[/-][+]Improve performance of startswith, endswith, count, *find, and *index methods for str, bytes and bytearray[/+]erlend-aasland commentedon Apr 3, 2024
Conversion of bytes/bytearray
find()and friends1 is not straight-forward: the first argument can be either a buffer or an index in the range [0,255]. The code is shared betweenbytesandbytearray2. My first thought would be to create a custom Argument Clinic converter3, but we'd want that also to be shared betweenbytesandbytearray.Footnotes
rfind, index, rindex, count ↩
Objects/bytes_methods.c↩a combination of one Argument Clinic Python input block and one C function ↩
pythongh-117431: Fix str.endswith docstring
gh-117431: Fix str.endswith docstring (#117499)
gh-117431: Adapt bytes and bytearray .startswith() and .endswith() to…
gh-117431: Adapt str.find and friends to Argument Clinic (#117468)
hugovk commentedon Apr 3, 2024
Nice work so far! Would be good to put these in What's New, perhaps under https://docs.python.org/3.13/whatsnew/3.13.html#optimizations.
Can be done later, when closing the issue.
pythongh-117431: Amend str method signatures after PR python#117468
gh-117431: Argument Clinic: copy forced text signature when cloning (#…
gh-117431: Adapt bytes and bytearray .find() and friends to Argument …
pythongh-117431: Adapt str.startswith and str.endswith to Argument Cl…
pythongh-117431: Fix str.endswith docstring (python#117499)
pythongh-117431: Adapt bytes and bytearray .startswith() and .endswit…
pythongh-117431: Adapt str.find and friends to Argument Clinic (pytho…
pythongh-117431: Argument Clinic: copy forced text signature when clo…
pythongh-117431: Adapt bytes and bytearray .find() and friends to Arg…