23 Mar 2010 kwa   » (Journeyer)

Announcing Greenlet 0.3

I’ve just released greenlet 0.3 on pypi. which has some bug fixes and a couple of new features.

Python 3 support

Greenlet now supports Python 3, and has been tested on Python 2.4, 2.5, 2.6, 3.0 and 3.1 on all platforms I have access to (x86 and amd64 GNU/Linux, x86 Windows, and Mac OS X Leopard).

Existing tests were rewritten so that they could be run without nose, since there is currently no stable release of nose for Python 3.

switch() now accepts keyword arguments

This is from the DWIM department. The switch method will now do what you expect with the arguments it receives.

>>> greenlet.greenlet(lambda: greenlet.getcurrent().switch()).switch()
>>> greenlet.greenlet(lambda: greenlet.getcurrent().switch(1)).switch()
>>> greenlet.greenlet(lambda: greenlet.getcurrent().switch(1, 2)).switch()
(1, 2)
>>> greenlet.greenlet(lambda: greenlet.getcurrent().switch(a=5)).switch()
{'a': 5}
>>> greenlet.greenlet(lambda: greenlet.getcurrent().switch(1, 2, a=5)).switch()
((1, 2), {'a': 5})


If you are writing an extension module, you can now use the provided header file to import greenlet, create greenlet objects and modify them directly from C.

PyObject *callable = ...
PyGreenlet *g = PyGreenlet_New(callable, NULL);
PyGreenlet_Switch(g, NULL, NULL);
    Py_BuildValue("s", "error message"),

See the documentation for a full API reference.

Platform updates

  • Linux mips support from Thiemo Seufer
  • MingGW GCC 4.4 support from Giovanni Bajo
  • Arm32 support from Sylvain Baro
  • Fixed Python 2.6 support on Windows from Armin Rigo

Bugs fixed

  • Switching to a new inactive greenlet created in another thread no longer crashes Python.
  • Fix for issue #40 from py lib to fix a threading bug. Patch from Armin Rigo and ghazel.

Documentation and tests

This release tripled the number of unit tests, and includes updated documentation based on the docs that used to be included in the py lib.

Known issues

  • #4: Build currently broken on Solaris Spark
  • #2: No support for x64 Windows
  • #5: No GC support. Creating reference cycles that include data in the stack frame of a greenlet can lead to leaks.

Getting greenlet

On most platforms, getting greenlet is easy. Just use pip or easy_install.

pip install --upgrade greenlet
easy_install -U greenlet

On Windows installing greenlet can be kind of tricky, since (without hackery) Visual Studio 2003 is required for Python versions < 2.6, and Visual Studio 2008 is required for later versions. For those who don’t want to go through the trouble, I’ve uploaded binary eggs and installers for x86 Windows to pypi, and the download page.

If you would like to report any bugs or request a feature, please create a new issue on bitbucket.

Tagged: greenlet, python

Syndicated 2010-03-23 22:51:36 (Updated 2010-03-23 22:55:00) from Ambroff's Log

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!