-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
gh-132042: Remove resolve_slotdups to speedup class creation #132156
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?
gh-132042: Remove resolve_slotdups to speedup class creation #132156
Conversation
Maybe take a look at this comment and have it in mind. |
@StanFromIreland Yeah, thanks! I just checked both scripts - and timing closely same. But I not finished main task, so results can changed. |
Intermediate results:
|
I added tests from gh-76527 (script for testing with pyperf b.txt):
Also benchgcclasses2.py output:
new:
Time varies, I'm not sure it is statistically significant. Count of objects closely the same. Async import time (
new:
|
Remove resolve_slotdups (new2):
|
It is ready to review. Please take a look. |
Objects/typeobject.c
Outdated
@@ -4432,30 +4425,33 @@ type_new_set_attrs(const type_new_ctx *ctx, PyTypeObject *type) | |||
return -1; | |||
} | |||
|
|||
if (type_new_set_module(type) < 0) { | |||
PyObject *dict = lookup_tp_dict(type); |
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.
Would it be possible to extract this change into a separated PR? It seems to be a perfectly reasonable change, but it's not directly renamed to "name_count".
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.
There are three optimizations - I will move each of them to own PR.
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 moved other two optimizations to separate PRs. Please take a look. Also, I think that news entry is not actual anymore and it is better to add it after all this PRs will be merged/rejected. WDYT?
@@ -16,6 +16,7 @@ struct wrapperbase { | |||
const char *doc; | |||
int flags; | |||
PyObject *name_strobj; | |||
uint8_t name_count; |
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.
Please add a comment explaining the purpose of this member and how it's computed. You can mention _PyType_InitSlotDefsNameCounts().
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.
Added a comment. Please take a look is this clear enough.
Co-authored-by: Victor Stinner <vstinner@python.org>
Updated results - only for remove resolve_slotdups (ran windows 11 x64 desktop, cpu- 11th Gen Intel(R) Core(TM) i5-11600K @ 3.90GHz):
|
Removes resolve_slotdups.