-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[librt] Add minimal librt.strings.StringWriter class (experimental) #20588
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
+792
−8
Conversation
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
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
p-sawicki
approved these changes
Jan 15, 2026
michaelm-openai
pushed a commit
to michaelm-openai/mypy
that referenced
this pull request
Jan 16, 2026
…ython#20588) It can be used to build a string from code points (via `append` method) and strings (via `write`). It's similar to `BytesWriter`, but it has to keep track of the kind of string being created (1/2/4 bytes per code point). I've optimized `append` but there are no mypyc primitives yet, so performance is still bad. I'll add mypyc primitives in a follow-up PR and do further optimizations as needed. There is no `truncate` or `__setitem__`, unlike `BytesWriter`, since these could require the recomputation of kind, and this would be inefficient. My current thinking is that we won't support these. I used LLM assist, especially for tests, but manually reviewed all changes.
michaelm-openai
pushed a commit
to michaelm-openai/mypy
that referenced
this pull request
Jan 16, 2026
…ython#20588) It can be used to build a string from code points (via `append` method) and strings (via `write`). It's similar to `BytesWriter`, but it has to keep track of the kind of string being created (1/2/4 bytes per code point). I've optimized `append` but there are no mypyc primitives yet, so performance is still bad. I'll add mypyc primitives in a follow-up PR and do further optimizations as needed. There is no `truncate` or `__setitem__`, unlike `BytesWriter`, since these could require the recomputation of kind, and this would be inefficient. My current thinking is that we won't support these. I used LLM assist, especially for tests, but manually reviewed all changes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It can be used to build a string from code points (via
appendmethod) and strings (viawrite). It's similar toBytesWriter, but it has to keep track of the kind of string being created (1/2/4 bytes per code point).I've optimized
appendbut there are no mypyc primitives yet, so performance is still bad. I'll add mypyc primitives in a follow-up PR and do further optimizations as needed.There is no
truncateor__setitem__, unlikeBytesWriter, since these could require the recomputation of kind, and this would be inefficient. My current thinking is that we won't support these.I used LLM assist, especially for tests, but manually reviewed all changes.