FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-107596: Specialize `str[int]` by brandtbucher · Pull Request #107597 · python/cpython · GitHub

/ cpython Public

GH-107596: Specialize str[int] - #107597

Merged
brandtbucher merged 7 commits into
python:mainfrom
brandtbucher:binary-subscr-str-int
Aug 8, 2023
Merged

GH-107596: Specialize str[int]#107597
brandtbucher merged 7 commits into
python:mainfrom
brandtbucher:binary-subscr-str-int

Conversation

brandtbucher commented Aug 3, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

This handles cases where a string (with any internal representation) is indexed by a medium nonnegative integer, resulting in an ASCII character.

Running the benchamarks/stats now...

brandtbucher added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Aug 3, 2023
brandtbucher self-assigned this Aug 3, 2023
Comment thread Python/specialize.c
PySlice_Check(sub) ? SPEC_FAIL_SUBSCR_TUPLE_SLICE : SPEC_FAIL_OTHER);
goto fail;
}
if (container_type == &PyUnicode_Type) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Would it be a good idea to check if the string is all ASCII, so we don't immediately deoptimise in that case? Or just support all characters by calling unicode_char in the opcode case, it's the last branch anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yeah, I think I'll just change the specialization to only support ASCII strings, rather than bothering with other widths. It's quick and easy to check, since strings know their encoding.

Copy link
Copy Markdown
Member Author

Well, I think I know which new benchmark is responsible for this showing up so prominently in the failure stats...

I'm going to modify this to only support ASCII strings, and see if that further improves things.

Copy link
Copy Markdown
Member Author

I'm going to revert that last change. Turns out the TOML benchmark that's hitting this so hard is indeed getting mostly ASCII characters out of "barely-Unicode" strings. So the original code is probably fine.

Copy link
Copy Markdown
Member Author

I'm happy with the benchmarks and stats.

brandtbucher merged commit ea72c6f into python:main Aug 8, 2023
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

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL