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
ast_opt.c -- missing posonlyargs? #83397
Comments
while fixing bpo-39215, I noticed that there seems to be a place here where posonlyargs was missed: Lines 617 to 627 in 7dc72b8
not sure if this is intentional or not -- happy to make a patch which adds a line there if someone can help me with the test |
Hi Anthony,
Thanks for the catch! Is not intentional. Could you made a PR adding the line?
We do not have explicit tests for constant folding in the ast level an, in this case, is going to be folded anyway via another code path. For example: def g():
def f(x : 3 in {1,2,3}, /): ...
return f
print(g.__code__.co_consts[2])
frozenset({1, 2, 3}) |
If you want to add a test, you could check the dis output for this example: def make_func(x):
def f(x : not (x is x), /): ... In this case the compiler emits: 3 0 LOAD_GLOBAL 0 (x) while for def make_func(x):
def f(x : not (x is x)): . emits more efficient code (using 'not is' instead of is and UNARY_NOT: 4 20 LOAD_GLOBAL 0 (x) Adding the missing line makes them do the same. |
Thanks again for the fix and the investigation! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: