bpo-36904: new function _PyStack_DictAsVector#13308
bpo-36904: new function _PyStack_DictAsVector#13308jdemeyer wants to merge 1 commit intopython:masterpython/cpython:masterfrom
Conversation
|
|
|
I'm wondering whether we should use a special |
| return NULL; | ||
| } | ||
| /* Truncate the tuple to the desired length */ | ||
| Py_SIZE(kwtuple) = nkwargs; |
There was a problem hiding this comment.
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_DictAsVectoras safe and more efficient replacement for_PyStack_UnpackDict.https://bugs.python.org/issue36904
https://bugs.python.org/issue36907