-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a tuple instead of a Thunk type #5
Comments
For immediate development on this pre PEP work, using a tuple certainly makes sense. For later: can we use a tuple for now, then convert to effectively to a It doesn't solve the unpacking con however. |
Here's a reasonably clean example from the I am reluctant to implement that; we'd probably need a new AST node type specifically for this purpose, and a new bytecode to construct the instance. E.g. this program: import ast
print(ast.dump(ast.parse("tag'xxx{yyy!r:spec}zzz'"), indent=2)) prints the following AST:
The bytecode looks like this:
We'd need a new In theory we could defer adding the |
I believe we've settled into a named tuple. We have one defined in this repo, but perhaps it should move over to Guido's branch and be part of CPython? If not, we should close this ticket. If so, should we follow current practice and make a |
It would be good if the Thunk implementation didn't require inheritance from a stdlib Thunk class. I am not in the mood to try and implement the Thunk class (and constructing instances from it in the bytecode) right now, we can work on that once the PEP is accepted. |
What if instead of passing a Thunk object for every interpolation, we just pass a tuple? So
ends up calling
PRO: It's easier to generate the code for this (no C code needed that implements a
Thunk
type).CON: Can't easily add another value to the tuple in the future (since people would write code that unpacks the tuple into exactly 4 variables).
The text was updated successfully, but these errors were encountered: