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

BINARY_SUBSCR_DICT should make use of keys versions #97578

Open
Fidget-Spinner opened this issue Sep 26, 2022 · 0 comments
Open

BINARY_SUBSCR_DICT should make use of keys versions #97578

Fidget-Spinner opened this issue Sep 26, 2022 · 0 comments
Labels
3.12 performance Performance or resource usage type-feature A feature request or enhancement

Comments

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commented Sep 26, 2022

Currently BINARY_SUBSCR_DICT just calls PyDict_GetItemWithError.

We should make use of dk_version for zero cost lookups on dictionaries.

Main problem I can think of:
Dictionaries used as a cache might frequently add and delete keys, so this would perform badly as deoptimizations would be frequent.

Solution: a modified function called PyDict_GetItemWithErrorCached. That takes in our _PyBinarySubscrCache and modifies that. On failure, instead of deoptimizing, just update the cache and go through the usual PyDict_GetItemWithError path. This isn't any slower than going through the unspecialized BINARY_SUBSCR and PyObject_GetItem routine.

I'm going to work on this at the sprint.
CC @markshannon and @iritkatriel.

@Fidget-Spinner Fidget-Spinner added type-feature A feature request or enhancement performance Performance or resource usage 3.12 labels Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 performance Performance or resource usage type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant