-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
bpo-27129: Use instruction offsets, not byte offsets, in bytecode and internally. #25069
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
Changes from all commits
05a6c62
5d3c577
2a93cf1
a6f3a79
db2f86b
325d135
3d3b995
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The bytecode interpreter uses instruction, rather byte, offsets internally. | ||
This reduces the number of EXTENDED_ARG instructions needed and streamlines | ||
instruction dispatch a bit. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1246,7 +1246,7 @@ PyTypeObject PyCode_Type = { | |
int | ||
PyCode_Addr2Line(PyCodeObject *co, int addrq) | ||
|
||
{ | ||
if (addrq == -1) { | ||
if (addrq < 0) { | ||
return co->co_firstlineno; | ||
} | ||
assert(addrq >= 0 && addrq < PyBytes_GET_SIZE(co->co_code)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not go a step further and divide the labels in dis output by 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. However now we have a confusing discrepancy between what's displayed and how we're encouraged to think about the bytecode in the C code. I guess there's no perfect answer, so status quo wins.