Repository navigation
[mypyc] Add librt.strings read/write functions for i8, u16, u32 and u64 - #22458
Merged
Merged
Conversation
Add write_u16/u32/u64_le/be and read_u16/u32/u64_le/be for packed unsigned binary data, following the existing signed variants. These can be used as faster alternatives to the struct "H", "I" and "Q" format codes in compiled code. Also add write_i8 and read_i8. Reading a signed byte previously required i8(u8(b[n])), since i8(b[n]) raises OverflowError for values above 127.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
jhance
approved these changes
Nov 13, 2026
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
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.
Add
write_u16_leandwrite_u16_be, and alsoread_functions and variants foru32andu64. These are very similar to the existing signed variants.Also add
write_i8andread_i8. Reading a signed byte previously requiredi8(u8(b[n])), sincei8(b[n])raises OverflowError for values above 127, so having dedicated functions is useful (unlike foru8).Work on mypyc/mypyc#1226.