bpo-46323: Reduce stack usage of ctypes python callback function.#31224
bpo-46323: Reduce stack usage of ctypes python callback function.#31224corona10 merged 6 commits intopython:mainfrom
Conversation
bc4d666 to
1bf3c7a
Compare
Modules/_ctypes/callbacks.c
Outdated
There was a problem hiding this comment.
Same workaroud
cpython/Modules/_ctypes/callproc.c
Lines 80 to 84 in 06e1701
52f5730 to
dcabd85
Compare
dcabd85 to
3754856
Compare
|
To clarify, this prevents stackoverflow in situations with repeated calls where argcount is small, but will have roughly the same amount of stack usage when argcount is around 1000 (very rare) , right? |
|
@sweeneyde Correct and also a little performance issue (See benchmark) |
fef8e28 to
dd5aded
Compare
dd5aded to
f4a276f
Compare
|
I think the title could be improved: "Reduce stack usage in Ctypes calls" or something. Right now, the mismatch is confusing between the title implying "use less stack" and the NEWS entry implying "use more stack". |
I've changed the title, Looks proper? |
| @@ -0,0 +1,3 @@ | |||
| :mod:`ctypes` now allocates memory on the stack instead of on the heap | |||
There was a problem hiding this comment.
There was no heap allocation directly before this PR, and there will be no heap allocation after, right? It's just eliminating that dead code path.
There was a problem hiding this comment.
@sweeneyde Yeah but this is the result of bpo-46323
There was a problem hiding this comment.
Victor and I decided to add NEWS entry for all this change at this moment.
Theoretically, we had to add NEWS entry at the first PR, but it's too late.
|
The change and title LGTM! |
|
@sweeneyde |
https://bugs.python.org/issue46323