kwa is currently certified at Journeyer level.

Name: Kyle Ambroff
Member since: 2005-08-19 17:11:40
Last Login: 2010-03-23 18:28:33

FOAF RDF Share This

Homepage: http://blog.ambroff.com

Projects

Recent blog entries by kwa

Syndication: RSS 2.0

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()
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.


Tagged: greenlet, python

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

Extension modules for unit tests with distutils

I’ve been hacking on greenlet lately, which has been in dire need of some tender loving care. The upcoming 0.3 release will include an API for extension modules that allows any extension module to create and manipulate greenlets directly in C without jumping through hoops.

I found myself wanting to add a test extension module to bring the C API under test, but it turns out that distutils doesn’t really support building extension modules that you don’t want to ship in the resulting binary distribution. In fact, when you run ”setup.py install”, distutils just copies the contents of build/lib.<platform>-<pyversion> to the target package.

The solution I came up with was pretty lame. greenlet has a tests package that provides a test collector function. Since some of the tests require an extension module to be built, the test collector will call tests.build_test_extensions(), which will manually compile the extension modules using distutils the same way that distutils.command.build_ext will, except that the resulting shared library is staged in build/temp.<platform>-<pyversion> before being copied into the source root.

The end result is similar to just adding the extension to setup.py, except that the test extensions don’t get installed. I’m definitely reporting this as a feature request for distutils2.


Tagged: greenlet, python

Syndicated 2010-03-23 01:32:45 from Ambroff's Log

Here at Linden Lab, I'm sometimes forced to make sure my code still works on Windows :P. Today I needed to install greenlet on Vista, and of course easy_install bailed since it requires Visual Studio 2003. As luck has it, 2003 doesn't work on Vista. I miss my shiny Ubuntu laptop!

The workaround I found with a little googling was to use MinGW to build the extension module.

  1. Download http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe and install it. Check g++ when asked to select components to install.
  2. Create C:\Python25\Lib\distutils\distutils.cfg with the following contents
    [build]
    compiler = mingw32
    
  3. Open a cmd shell and add C:\MinGW\bin to your path
    set PATH=C:\MinGW\bin;%PATH%
  4. Install greenlet!
    C:\Python25\Scripts\easy_install.exe -U
    greenlet

LRL Live USA

Brandon and I are going to Lugradio Live USA 2008 on April 11th and 12th. It is going to kick ass! If you are anywhere near California, you must go. You don’t have any excuses.

As an added birthday bonus, I’ll be attending as a new LindenLab employee! For those of you who might not have heard of them, LindenLab is the creator of the online virtual world Second Life. I was recently offered the position of Release Engineer, and my first day is on the 7th of April. Joy! I am so excited to start that I can hardly think about anything else. It looks like my new avitar is going to be Ambroff Linden, so come see me in-world!

PS: I can’t wait to see abock all oiled up in a thong.

Syndicated 2008-03-28 02:57:00 from Code walking

Source code licencing == term paper policy

Something Luis Villa posted today reminded me of an experience I had recently with a group of students. I am reminded of a phrase that I heard while discussing software licensing. “If we change 60% of the code, it’s ours.”

I am about to graduate with a BS in Computer Science from CSU Sacramento, which means that I’m currently working on my senior project.

My department’s senior project course is a little different at other schools I suspect, since it is a group project with 3 to 6 members per team, and spans two semesters. Also, rather than just coming up with a proposal for an interesting problem to solve, students compete to get a fake contract with one of several local businesses and government agencies. It’s good I guess, but I’d rather be hacking on GNOME or some other free software than write yet-another-boring-crm for tracking form submissions :-). It usually feels more like an exercise in paper pushing than designing software anyway, since the projects are quite simple and boring.

Anyway, me and a fellow teammate were discussing plans for a rather complicated custom widget we needed to create for this project. He found an example that some Joe Schmo had posted on the Internet without any license information, and wanted to just start with that and modify it where necessary.

My first thought was to ask if he knew anything about the license that the code was released under. His first reaction was to stare blankly at me, which I can understand, but this next part shocked me. I said, “Well, if he didn’t explicitly grant any rights to use and redistribute this code, the safe thing to ask him to release it under MIT X11, GPL, or any other license compatible with our codebase.”

He responded, “Why do we need to do that. If we change more than 60% of it then the code is ours.”

My jaw hit the floor. I didn’t even know how to respond to this. After a discussion about U.S. Copyright law, licensing, Copyleft and the four freedoms, etc., we had things straightened out. But I was still troubled.

I think that he may have been confusing one of his instructor’s plagiarism policies with copyright law. I find this especially disturbing because as a computer science student, he is required to take a course that explicitly covers Copyright, Patent and Trademark law. What is even more disappointing is that he is not alone. From my experience, many, many students in this department make the same mistake.

Maybe a question involving this topic would be a good weed-out question when hiring developers who will be working on free software? I would love to see the responses.

Syndicated 2008-03-28 02:49:13 from Code walking

8 older entries...

 

kwa certified others as follows:

  • kwa certified kwa as Apprentice
  • kwa certified sri as Journeyer
  • kwa certified jdub as Master
  • kwa certified harold as Master
  • kwa certified dmarti as Master
  • kwa certified rms as Master
  • kwa certified mjg59 as Master

Others have certified kwa as follows:

  • kwa certified kwa as Apprentice
  • zx80user certified kwa as Apprentice
  • aicra certified kwa as Apprentice
  • richdawe certified kwa as Apprentice
  • Zaitcev certified kwa as Journeyer

[ Certification disabled because you're not logged in. ]

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!

X
Share this page