Hasty Briefsbeta

Bilingual

CPython discussion on official support for adding virtual threads

a year ago
  • #concurrency
  • #python
  • #virtual-threads
  • Java has virtual threads, which are a better concurrency model than Python's async/await.
  • Virtual threads combine the benefits of normal threads (no new syntax, intuitive execution) and async tasks (lightweight, structured concurrency).
  • Unlike Python's coroutines, virtual threads do not split the language into 'colors' (sync vs. async).
  • Virtual threads can be implemented in Python using continuations for context switching and non-blocking calls.
  • Continuations in Python would allow stackful and symmetric coroutines, enabling better context switching.
  • Non-blocking calls in virtual threads can be achieved by managing async operations via an event loop continuation.