-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-36904: new function _PyStack_DictAsVector #13308
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
Conversation
|
I'm wondering whether we should use a special |
} | ||
/* Truncate the tuple to the desired length */ | ||
Py_SIZE(kwtuple) = nkwargs; |
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.
That doesn't look safe at all. Won't such a tuple join the wrong freelist in tupledealloc
?
I didn't think of the freelist but it's true that I already had bad feelings about messing with the tuple size like that. What do you think of my proposal (see above) of making a special |
For a good answer I'd need to write the code :)
|
write the code or just see the code (written by me for example)?
This two-step process is going to take more work: it requires to discuss two API designs and implementations instead of one (with the first one going to be thrown away anyway once we do the second). So, I'd like to do it in one step if possible. |
On the other hand, adding the "refcount poking" part is pretty simple. So if you agree with doing just that manually (without changing |
For a relatively complex optimization? benchmark the code, before and after.
But without the first, it'd be hard to argue that the tuple subclass actually brings any benefit. Tuple subclasses behave quite differently from exact tuples (they don't use freelists, for one).
Definitely! All I ask for before the optimization is a correct baseline. It might then very well turn out that the optimization is unnecessary. |
I decided to drop this idea. It's more controversial than I initially thought and I see why (I can't disagree). For reference: #14517 optimized |
Provide
_PyStack_DictAsVector
as safe and more efficient replacement for_PyStack_UnpackDict
.https://bugs.python.org/issue36904
https://bugs.python.org/issue36907