Use 1 byte per type/symbol tag#19735
Merged
ilevkivskyi merged 3 commits intopython:masterfrom Aug 26, 2025
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
JukkaL
reviewed
Aug 26, 2025
mypyc/primitives/misc_ops.py
Outdated
| ) | ||
|
|
||
| function_op( | ||
| name="native_internal.write_native_internal", |
Collaborator
There was a problem hiding this comment.
Should the name be ...write_tag, similar to the above ones?
Member
Author
There was a problem hiding this comment.
Oops, it looks like some Ctrl+R went wrong :-) Will fix it.
mypyc/primitives/misc_ops.py
Outdated
| name="native_internal.write_native_internal", | ||
| arg_types=[object_rprimitive, int_rprimitive], | ||
| return_type=none_rprimitive, | ||
| c_function_name="write_native_internal_internal", |
Collaborator
There was a problem hiding this comment.
Should this be write_tag_internal?
mypyc/primitives/misc_ops.py
Outdated
| ) | ||
|
|
||
| function_op( | ||
| name="native_internal.read_native_internal", |
mypyc/primitives/misc_ops.py
Outdated
| name="native_internal.read_native_internal", | ||
| arg_types=[object_rprimitive], | ||
| return_type=int_rprimitive, | ||
| c_function_name="read_native_internal_internal", |
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
JukkaL
approved these changes
Aug 26, 2025
Collaborator
As discussed offline, I think that this is a good idea (if it doesn't cause any trouble). I think it's okay to do this in a follow-up PR, but it's up to you. |
Member
Author
|
OK, I will make a separate PR for |
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.
This is a small incremental improvement for fixed format cache. I am adding a dedicated write/read functions for tags (i.e. integers in 0-255 range). I propose to exclusively use these functions for type tags (hence the name), and still use regular
write_int()/read_int()for integers that are "accidentally small" (like argument kinds etc). In a separate PR I will change regularintformat to be more progressive (e.g. only use 1 byte if an integer happens to be small). I also change the terminology from "marker" to "tag", as this is a more common name for this concept.Note we can probably use
mypy_extensions.u8for type tags. If there is a desire for this, I can switch to it (either in this or a separate PR).