[Cython] Implemented Set/FrozenSet support for Python 2.3

Stefan Behnel stefan_ml at behnel.de
Sat Oct 25 13:02:37 CEST 2008


Hi,

Stefan Behnel wrote:
>> Lisandro Dalcin wrote:
>>> 1) You have a 'cython.py' script. This script just add 'set' and
>>> 'frozenset' to __builtin__ module for the case of Python 2.3.
>> IMHO, the compiler shouldn't mingle with __builtins__, so this must be handled
>> directly in Cython as a special case.
> 
> I just noticed that that special casing code is more or less there already in
> Builtin.py. I'll see if I can fix your patch up.

Ok, I have committed a patch that works for me on Py2.3-2.6.

http://hg.cython.org/cython-devel/rev/303c79051806

One thing I noticed is that at least a part of the set API is already in
Py2.4, so I had to move some of the replacements into a separate Py2.4
section. This is not in line with the Python C-API docs, which state that the
set API is new in Py2.5. I guess it just wasn't officially made public in Py2.4.

Please review the commit for now, I'll also take another look at the Py2.4
issue myself.

> Aaron, given that you requested this feature, could you come up with a good
> doctest for sets? See tests/run/*.pyx for examples on how it's done.

There already was a test for sets: tests/run/set.pyx. It was just disabled
explicitly for Py2.3. It now works for all supported Python versions.

Stefan



More information about the Cython-dev mailing list