Implement tuple in the stdlib#402
Merged
Merged
Conversation
Merged
antocuni
added a commit
that referenced
this pull request
Feb 24, 2026
From the comment in ast.py: ``` # The Expr class has an optional field w_T which indicates the type of the expression. # # AST trees are said UNTYPED when all their Exprs have w_T == None. # AST trees are said TYPED when all their Exprs have w_T != None. # # It is a logical error to have AST trees which mix typed and untyped nodes. # # The parser produces UNTYPED ASTs. DopplerFrame produces TYPED ASTs. ``` This will be useful because the it allows the C backend to know the type of expressions. In particular it's needed for tuple unpacking (PR #402) and "preserve left-to-right arg evaluation" (PR #386 which is now closed and will be redone in a different way). @Jemeljanov this is probably what you will need for your PR :)
0e3e269 to
750cc7b
Compare
…s built by the tests
…ame. Works in [interp] so far
750cc7b to
652ca65
Compare
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.
Introduce
stdlib/_tuple.spy, which implementstuplein SPy and thus it's automatically supported by the C backend.Tuples are implemented as structs like this:
Moreover, the "tuple packing" syntax now automatically infers the right tuple type and creates an instance of it:
STATIC_TYPE((1, 'hello')) == tuple[int, str].Similarly, we support tuple unpacking:
a, b = sometuple.The old "blue only, untyped tuple" now lives in
__spy__.interp_tuple. It's still used for*varargs.Unrelated misc changes:
libspy.wasmin a way that always include/exports all the symbols which might be needed in tests