Skip to content
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-115776: Allow any fixed sized object to have inline values #123192

Merged
merged 9 commits into from
Aug 21, 2024

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Aug 21, 2024

Currently only objects with Py_TYPE(obj)->tp_basicsize == sizeof(PyObject) are allowed to have inline values.
This PR changes that to allow any object where all instances of the class have the same size to have inline values.

Performance is in the noise, but the stats show a clear reduction in the number of LOAD_ATTRs executed.
Oddly, the number of LOAD_ATTR_INSTANCE_VALUEs executed is roughly unchanged, the new specializations being for class attributes. Fixing the shadowing issue should improve things further and show an increase in LOAD_ATTR_INSTANCE_VALUEs.

Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this stuff documented anywhere?

@markshannon
Copy link
Member Author

Is this stuff documented anywhere?

Good point.

@markshannon markshannon merged commit a4fd7aa into python:main Aug 21, 2024
57 checks passed
@hauntsaninja
Copy link
Contributor

It looks like this PR broke a test in the mypyc transpiler: python/mypy#17973
I suspect it's something funky when calling PyObject_SetAttr(obj, "__dict__", {"x": 10})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants