Skip to content

Conversation

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jan 13, 2026

The approach is similar to #20552, which added a fast inlined implementation of bytes get item. However, we do it for ord(str[n]) instead of just str[n], since the latter produces a reference-counted string of length 1, which is often too slow for performance-critical code. Later on the idea is to add a string writer class that supports quickly appending unicode code points represented as integers.

This makes a micro-benchmark that finds the highest unicode code point in a string about 18x faster.

@JukkaL JukkaL merged commit 59257a2 into master Jan 13, 2026
17 checks passed
@JukkaL JukkaL deleted the mypyc-ord-str branch January 13, 2026 17:44
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.

3 participants