-
Notifications
You must be signed in to change notification settings - Fork 51
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Merge co_names and co_consts into a single array. #92
Comments
Are there no backwards compatibility issues? They are both part of the api. Also, would this make the consts not immutable from user code? That would probably be an api change. |
That would be easy to validate by counting these numbers in the top 100 or 5000 packages on GitHub. |
Using the top 1000 PyPI packages, I got 0.14% of code objects having more than 256 total names and constants combined.
https://github.com/pxeger/pycstats Edit: updated data with top 1000 packages |
But how often are they >= 255 together? Also, it looks like to minimize extended-arg opcodes we need to place the names first. (The dynamic profile could theoretically be different, but that feels unlikely.) |
I'm not sure what you mean by "But how often are they >= 255 together?". The 0.12% number is already the proportion for which |
Oh, d’oh. Of course. Sorry! |
The array would be internal, so could not be mutated. |
Could you update the initial comment to clarify that (a lot)? This wasn't obvious to me at all (though I'm sure it was in your mind when you wrote it down :-). |
I didn't want to shackle whoever was going to implement it :) Now that I've given a bit of thought, here's another way to implement it: The consts and names go in the same array (names first, but it doesn't really matter), and we store a pointer to the first const. E.g. names:
|
When I experimented with MAKE_INT there was a noticeable difference in micro benchmarks between the opcode doing small_ints[oparg] and small_ints[oparg-5]. |
@iritkatriel OOI what was the difference between the two? |
Start here: #65 (comment) |
Presumably |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Merging
co_names
andco_consts
would have some significant benefits:The obvious downside is for functions where the total number of names and constants exceeds 256. I hypothesize that those functions are rare, but don't have data to confirm that.
This is probably best left until https://bugs.python.org/issue36521 has been resolved.
The text was updated successfully, but these errors were encountered: