Use u8 for type/symbol tags#19741
Conversation
This comment has been minimized.
This comment has been minimized.
Yes, a literal integer should always be valid if |
| assert read_tag(b) == 33 | ||
| assert read_tag(b) == 255 | ||
| assert read_tag(b) == TAG_A | ||
| assert read_tag(b) == TAG_B |
There was a problem hiding this comment.
Try reading the error value (when there is no error).
There was a problem hiding this comment.
Oh, good idea, I will add it to both compiled and interpreted tests.
To be clear, it doesn't give an error, but mypyc generates slow code in case where I would expect it to generate fast code. Looking more at this, I think this works correctly for code like |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
While trying this I found that this is a bit fragile, in the sense that
write_tag(data, 1)(with a literal1) will not get specialized and will go through slow path (btw @JukkaL is this a bug, should type of a literal in fixed int type context be inferred as fixed int?) OTOH this is probably not a big deal since no-one will usewrite_tag()with literals, it will always be something likewrite_tag(data, FUNC_DEF).