-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-47215: Add undocumented, unstable FrameStack API for use by greenlets and similar libraries. #32303
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
@@ -364,3 +368,16 @@ typedef int (*crossinterpdatafunc)(PyObject *, _PyCrossInterpreterData *); | |||
|
|||
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc); | |||
PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *); | |||
|
|||
/* UNSTABLE API for stackful coroutines. |
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.
What about hiding this behind an ifdef, it would technically be an api break, but would make the intention clearer:
#ifdef _PYTHON_C_UNSTABLE_FRAMESTACK_API
...
#endif
Sorry, I didn't get a chance to look at this too closely today. My plan is to attempt to modify my fork of Greenlet tomorrow to see how well it works with this branch (and then we'll have a patch we can upstream right away, too). A few thoughts just from looking at this so far:
We can also loop in the Greenlet maintainers and get their opinion on this. @jamadden? |
The default size is 64k, which is fine for a thread, but quite large for a coroutine. It costs nothing to expose it. The problem with a save/restore model is that it has too many states and error conditions. What state is the VM in after mutliple saves, with no restore? Or vice versa? For performance reasons the frame stack struct needs to be embedded in the thread state, so we can't return a pointer to it. |
Skipping news, as I want to keep this as low key as possible.
We want this for greenlets, we don't want it misused by other third party code.
@brandtbucher would this cover greenlet's needs?
https://bugs.python.org/issue47215