# Add Virtual Threads to Python

**URL:** <https://discuss.python.org/t/add-virtual-threads-to-python/91403>\
**Category:** Ideas\
**Created:** [May 9, 2025, 5:33pm UTC](https://discuss.python.org/t/add-virtual-threads-to-python/91403 "2025-05-09T17:33:14Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![markshannon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/markshannon/32/72_2.png) [@markshannon](https://discuss.python.org/u/markshannon)\
**Post date:** [May 11, 2025, 10:46pm UTC](https://discuss.python.org/t/add-virtual-threads-to-python/91403/23 "2025-05-11T22:46:47Z")

</div>

> 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 🙂

---

_[View the full topic](https://discuss.python.org/t/add-virtual-threads-to-python/91403)._
