-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-100239: specialize dict subclasses with no getitem override #132383
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
base: main
Are you sure you want to change the base?
Conversation
|
The tests will be great again once we merge the fix for #132284. |
Python/bytecodes.c
Outdated
| PyObject *dict = PyStackRef_AsPyObjectBorrow(dict_st); | ||
|
|
||
| assert(PyDict_CheckExact(dict)); | ||
| assert(PyDict_Check(dict)); |
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 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.
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.
|
Perf with the fix to the guard: https://github.com/faster-cpython/benchmarking-public/blob/main/results/bm-20250412-3.14.0a7%2B-3d9cf36/README.md |
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.
Is it worth making dict_subscript non-static to avoid the indirection PyDict_Type.tp_as_mapping->mp_subscript?
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.
It looks like the test_opcode test needs updating.

Perf stats show the specialisation numbers improve, but perf is overall the same.
https://github.com/faster-cpython/benchmarking-public/blob/main/results/bm-20250410-3.14.0a6%2B-bf2d1dd/README.md