greenlet

Lightweight in-process concurrent programming

65 个版本 Python >=3.10
安装
pip install greenlet
poetry add greenlet
pipenv install greenlet
conda install greenlet
描述

.. This file is included into docs/history.rst

Greenlets are lightweight coroutines for in-process concurrent programming.

The "greenlet" package is a spin-off of Stackless_, a version of CPython that supports micro-threads called "tasklets". Tasklets run pseudo-concurrently (typically in a single or a few OS-level threads) and are synchronized with data exchanges on "channels".

A "greenlet", on the other hand, is a still more primitive notion of micro-thread with no implicit scheduling; coroutines, in other words. This is useful when you want to control exactly when your code runs. You can build custom scheduled micro-threads on top of greenlet; however, it seems that greenlets are useful on their own as a way to make advanced control flow structures. For example, we can recreate generators; the difference with Python's own generators is that our generators can call nested functions and the nested functions can yield values too. (Additionally, you don't need a "yield" keyword. See the example in test_generator.py <https://github.com/python-greenlet/greenlet/blob/adca19bf1f287b3395896a8f41f3f4fd1797fdc7/src/greenlet/tests/test_generator.py#L1>_).

Greenlets are provided as a C extension module for the regular unmodified interpreter.

.. _Stackless: http://www.stackless.com

Who is using Greenlet?

There are several libraries that use Greenlet as a more flexible alternative to Python's built in coroutine support:

  • Concurrence_
  • Eventlet_
  • Gevent_

.. _Concurrence: http://opensource.hyves.org/concurrence/ .. _Eventlet: http://eventlet.net/ .. _Gevent: http://www.gevent.org/

Getting Greenlet

The easiest way to get Greenlet is to install it with pip::

pip install greenlet

Source code archives and binary distributions are available on the python package index at https://pypi.org/project/greenlet

The source code repository is hosted on github: https://github.com/python-greenlet/greenlet

Documentation is available on readthedocs.org: https://greenlet.readthedocs.io

版本列表
3.5.2 2026-06-17
3.5.1 2026-05-20
3.5.0 2026-04-27
3.4.0 2026-04-08
3.3.2 2026-02-20
3.3.1 2026-01-23
3.3.0 2025-12-04
3.2.5 2026-02-20
3.2.4 2025-08-07
3.2.3 2025-06-05
3.2.2 2025-05-09
3.2.1 2025-04-22
3.2.0 2025-04-15
3.1.1 2024-09-20
3.1.0 2024-09-10
3.0.3 2023-12-21
3.0.2 2023-12-08
3.0.1 2023-10-25
3.0.0 2023-10-02
3.0.0rc3 2023-09-12
3.0.0rc2 2023-09-09
3.0.0rc1 2023-09-01
3.0.0a1 2023-06-21
2.0.2 2023-01-28
2.0.1 2022-11-07
2.0.0 2022-10-31
2.0.0.post0 2022-11-03
2.0.0rc5 2022-10-31
2.0.0rc4 2022-10-30
2.0.0rc3 2022-10-29
2.0.0rc2 2022-10-28
2.0.0rc1 2022-10-27
2.0.0a2 2022-03-24
2.0.0a1 2022-01-20
1.1.3 2022-08-25
1.1.3.post0 2022-10-10
1.1.2 2021-09-29
1.1.1 2021-08-06
1.1.0 2021-05-06
1.0.0 2021-01-13
1.0a1 2020-11-20
0.4.17 2020-09-22
0.4.16 2020-06-05
0.4.15 2018-09-07
0.4.14 2018-07-17
0.4.13 2018-01-31
0.4.12 2017-02-01
0.4.11 2016-12-10
0.4.10 2016-06-12
0.4.9 2015-08-30
0.4.7 2015-05-16
0.4.6 2015-05-03
0.4.5 2014-10-18
0.4.4 2014-09-07
0.4.3 2014-08-07
0.4.2 2014-01-07
0.4.1 2013-06-07
0.4.0 2012-06-21
0.3.4 2012-02-11
0.3.3 2012-01-06
0.3.2 2011-12-15
0.3.1 2010-04-06
0.3 2010-03-24
0.2 2010-02-25
0.1 2006-01-10