-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Odd Bytecode Generation in 3.10 #90880
Comments
I noticed that in Python 3.10, and also in main, a certain control flow construct produces some very odd bytecode (showing on main but same on python 3.10 tags):
The last JUMP_FORWARD has a rather larger argument! This was the minimal example I could find to replicate this. However, this is an example of some runnable code that also encounters it:
This actually executes fine, but I notice that when it's executing it does execute that very large arg, but that the I am not sure if this is a bug or intended behavior. It does seem a bit odd to have this unnecessarily large argument that ends up turning into a negative jump! But the behavior seems fine. At the least, maybe |
I added a patch to make I am looking into why the bytecode is emitted like this in the first place now. I see that currently, Python is trying to write a negative bytecode arg for the JUMP_ABSOLUTE and |
Ah, I see that to represent a negative 4 byte signed integer as an arg, we actually do need the 4 instructions, since each is a byte, to get the most significant bit to a 1? I wasn't able to find anything anywhere which says if the bytecode should or should not contain negative opargs, so I am not sure if this is a bug or intended behavior, to emit the three EXTENDED_ARGs in order to represent |
I think this is fixed (for 3.11 at least) by #31888 |
I'm not seeing it on 3.10 anymore either:
|
JUMP_ABSOLUTE
for all backward jumps. #31326JUMP_ABSOLUTE
for all backward jumps. #31352JUMP_ABSOLUTE
for all backward jumps. (GH-31326) #31354Note: 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: