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
GH-99554: Pack location tables more effectively #99556
Conversation
Python/compile.c
Outdated
static inline bool | ||
same_location(location a, location b) | ||
{ | ||
if (a.lineno < 0 && b.lineno < 0) { |
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.
I’d check also that they are the same value in case we will want to distinguish between ‘no location’ and ‘unknown location’ or something like that.
(I’m assuming you don’t rely on the full equality check because we’re inconsistent about what the other 3 values are).
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.
Should an "unknown location" ever exist? That sounds like a compiler bug.
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.
I'm thinking of cases where we just want to take the location of the previous instruction. Currently we just say "NO_LOCATION", but would we ever want to distinguish between this case and the case where there truly is no location (because the instructions are fake)? I don't know, but we might not want to rule it out.
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.
(I’m assuming you don’t rely on the full equality check because we’re inconsistent about what the other 3 values are).
Actually, it appears that we can remove this special case entirely. Just using the full equality check results in the exact same PYC sizes for the entire stdlib.
|
Name | Link |
---|---|
be7eb0a | |
https://app.netlify.com/sites/python-cpython-preview/deploys/639b60d4868560000855722c | |
https://deploy-preview-99556--python-cpython-preview.netlify.app | |
To edit notification comments on pull requests, go to your Netlify site settings.
|
static inline bool | ||
same_location(location a, location b) | ||
{ | ||
return a.lineno == b.lineno && |
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.
According to git diff you have a trailing space here. Surprised CI didn't catch it?
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.
Wow, nice catch! I'll fix it.
This shrinks the size of
.pyc
files by about 10%. It also shrinks the memory footprint of all code objects in the process..pyc
files are larger than they need to be #99554