-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mypyc] Foundational support for tuple literals (+ None and bool) (#1…
…0041) Add support for loading tuple literals using `LoadLiteral`. The literal tuple objects will be constructed during module import time, similar to other literals. Only tuples containing items of supported literal types can be represented (this includes other tuples). Add `None`, `True` and `False` to the literals array so that they can be used as tuple literal items. Currently tuple literals aren't used for anything. I added some unit tests to check parts of the implementation. The primary use case I have in mind is supporting vectorcall APIs which expect a tuple of keyword argument names. I will implemented this in a separate PR. This will also add some end-to-end testing for tuple literals. These could be used to avoid repeatedly constructing tuples with literal values in other contexts as well. Use array-based encoding for tuple literal values. We use the literal object array introduced in #10040 to allow a simple integer-based encoding of heterogeneous tuples. For example, tuple `('x', 5)` could be encoded like this as three integers: * 2 (length of tuple) * 123 (index of literal `'x'`) * 345 (index of literal `5`)
- Loading branch information
Showing
7 changed files
with
148 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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