Skip to content

gh-100239: specialize dict subclasses with no getitem override#132383

Closed
iritkatriel wants to merge 6 commits into
python:mainfrom
iritkatriel:dicts
Closed

gh-100239: specialize dict subclasses with no getitem override#132383
iritkatriel wants to merge 6 commits into
python:mainfrom
iritkatriel:dicts

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Apr 11, 2025

Copy link
Copy Markdown
Member

@iritkatriel iritkatriel changed the title gh-100239: spcialize dict subclasses with no getitem override gh-100239: specialize dict subclasses with no getitem override Apr 11, 2025
@iritkatriel

Copy link
Copy Markdown
Member Author

The tests will be great again once we merge the fix for #132284.

Comment thread Python/bytecodes.c Outdated
PyObject *dict = PyStackRef_AsPyObjectBorrow(dict_st);

assert(PyDict_CheckExact(dict));
assert(PyDict_Check(dict));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you also need to change _GUARD_NOS_DICT to PyDict_Check instead of PyDict_CheckExact for this to work but I am not sure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It does look like it from the code, but I don't see more misses.

image

@iritkatriel

Copy link
Copy Markdown
Member Author

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it worth making dict_subscript non-static to avoid the indirection PyDict_Type.tp_as_mapping->mp_subscript?

Comment thread Python/bytecodes.c Outdated
@iritkatriel iritkatriel requested a review from methane as a code owner April 14, 2025 15:32

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like the test_opcode test needs updating.

Comment thread Python/bytecodes.c Outdated
Comment thread Python/specialize.c Outdated
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 23, 2026
@kumaraditya303

Copy link
Copy Markdown
Contributor

Superseded by #148128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge skip news stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants