I'm interested in continuations, specifically in Python's C-API. From what i understand, the nature of continuations requires un-abstracting low-level calling conventions in order to manipulate the call stack as needed. I was fortunate enough to come across a few examples of these scattered here and there. In the few examples i've come across, this un-abstraction is done using either clever C (with assumptions about the environment), or custom assembly.
However, what's cool about Python is that it has its own interpreter stack made up of PyFrameObject
s. Assuming single-threaded applications for now, shouldn't it be enough to just switch in-and-out PyFrameObjects
s to implement continuations in Python's C-API? Why do these authors even bother with the low-level stuff?