Add Virtual Threads to Python

I’m also not sure how you’d simultaneously:

  • have clearly defined context switches
  • not have function coloring (even excluding the interaction with async/await)
  • not have an issue with ffi

It depends on what you mean by an issue with ffi. Context switching from Python code that has been called from C code, that has been called from Python within the continuation will raise.
That is a limitation of any portable implementation of continuations without significant C API extension.
If this is deemed insufficient by the community, then we can look to implement a (complex) C API to support suspension, or incorporate what gevent does and swap the C stack.

Any two of these are accomplishable trivially

I’m glad you consider it trivial, others in this discussion seemed to be implying it would be too difficult :slight_smile:

1 Like