<> = 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 模块暴露出来的功能其实只有其中很少的一部分。通过阅读以下页面提供的信息,你将会对这些概念熟悉起来的: * [[http://www.stackless.com/wiki/Tasklets|Microthreads]]. Tasklets 对函数进行包装,然后便可以作为微线程而启动。 * [[http://www.stackless.com/wiki/Channels|Channels]]. Channels 可以用来在 tasklets 之间进行双向的通讯。 * [[http://www.stackless.com/wiki/Scheduling|Scheduling]]. 内置了一个 round robin 调度器。它可以以合作或抢占式两种方式对 tasklets 进行调度。 * [[http://www.stackless.com/wiki/Pickling|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: * [[http://www.stackless.com/wiki/Tasklets|Microthreads]]. Tasklets wrap functions allowing them to be launched as microthreads. * [[http://www.stackless.com/wiki/Channels|Channels]]. Channels can be used for bidirectional communication between tasklets. * [[http://www.stackless.com/wiki/Scheduling|Scheduling]]. A round robin scheduler is built in. It can be used to schedule tasklets either cooperatively or preemptively. * [[http://www.stackless.com/wiki/Pickling|Serialisation]]. Tasklets can be serialised to disk through pickling for later resumption of execution. == 相关文档 == * [[http://www.stackless.com/|官方首页]] * [[http://members.verizon.net/olsongt/stackless/|Introduction to Concurrent Programming with Stackless Python]] * [[http://www.python.org/workshops/2000-01/proceedings/papers/tismers/spcpaper.htm|Continuations and Stackless Python Or "How to change a Paradigm of an existing Program"]] * [[http://www.python.org/dev/peps/pep-0219/|pep-0219 Stackless Python]] * [[http://codespeak.net/svn/pypy/dist/pypy/doc/discussion/howtoimplementpickling.txt|Designing thread pickling or "the Essence of Stackless Python"]] * [[http://harkal.sylphis3d.com/2005/08/10/multithreaded-game-scripting-with-stackless-python/|Multithreaded Game Scripting with Stackless Python]] * [[http://www.imperialviolet.org/stackless/|Stackless]] * [[http://willware.net:8080/uthread.html|Python Microthreads]] == 相关代码 == * [[HuangYi/yield_stacklesspython| 使用 yield 模拟 stacklesspython, 也许能帮助理解其机制]] == 讨论 ==