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()
1
>>> 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})
C API
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);
PyGreenlet_Throw(
PyExc_ValueError,
Py_BuildValue("s", "error message"),
NULL);
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.
March 23, 2010 at 11:03 pm |
Dude! Awesome!
Thanks especially for the C API. It would be really helpful to me if there was also C API for registering non-python callbacks. void (*callback)(void * data) which could make greenlet useful even without the presence of Python.h.
March 24, 2010 at 1:29 am |
[...] This post was mentioned on Twitter by Denis Bilenko, Denis Bilenko and Kyle Ambroff, Nicholas Piël. Nicholas Piël said: RT @ambroff: Just released Greenlet 0.3: http://bit.ly/bI22W1 (via @gevent) [...]
April 1, 2010 at 4:05 am |
Thanks for your work!
May 12, 2010 at 11:12 am |
What is the state of the x64 Windows port? A while ago I have ported greenlet-0.2 to win-amd64 using code from stackless. I could attempt to do it again for greenlet 0.3.
July 21, 2010 at 4:58 am |
Great post! Keep up the good work
August 17, 2010 at 6:08 pm |
Wanted to know the state of Solaris 10 SPARC Build :(.. only servers we have in my company… ;(