Stackless Python
简介
Stackless Python 是 Python 编程语言的一个增强版本。它能让程序员在获得基于线程编程的好处的同时,还不用考虑传统线程带来的性能和灵活性的问题。由 Stackless 添加到 Python 中的微线程是一个便宜且轻量的便利工具,如果用得恰当的话,它能提供以下好处:
- 改良程序结构
- 增强代码可读性
- 提高程序员生产力
Stackless Python is an enhanced version of the Python programming language. It allows programmers to reap the benefits of thread-based programming without the performance and complexity problems associated with conventional threads. The microthreads that Stackless adds to Python are a cheap and lightweight convenience which can if used properly, give the following benefits:
- Improved program structure.
- More readable code.
- Increased programmer productivity.
特性
对于所有通过使用 Stackless 所能获得的便利来说,通过 stackless 模块暴露出来的功能其实只有其中很少的一部分。通过阅读以下页面提供的信息,你将会对这些概念熟悉起来的:
Microthreads. Tasklets 对函数进行包装,然后便可以作为微线程而启动。
Channels. Channels 可以用来在 tasklets 之间进行双向的通讯。
Scheduling. 内置了一个 round robin 调度器。它可以以合作或抢占式两种方式对 tasklets 进行调度。
Serialisation. Tasklets 可以通过 pickling 序列化到磁盘上,稍后再继续执行。
For all the convenience gained through using Stackless, there is really only a minimal amount of functionality exposed through the stackless module. You can get more familiar with these aspects by reading the information provided in the following pages:
Microthreads. Tasklets wrap functions allowing them to be launched as microthreads.
Channels. Channels can be used for bidirectional communication between tasklets.
Scheduling. A round robin scheduler is built in. It can be used to schedule tasklets either cooperatively or preemptively.
Serialisation. Tasklets can be serialised to disk through pickling for later resumption of execution.
相关文档
Introduction to Concurrent Programming with Stackless Python
Continuations and Stackless Python Or "How to change a Paradigm of an existing Program"
Designing thread pickling or "the Essence of Stackless Python"
相关代码