On Thu, Oct 23, 2008 at 3:08 AM, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> It can't use PySet_* anyway, as they are not available in Py2.3, and > Cython code currently runs with 2.3. Although I wouldn't mind restricting > the C code to Py2.4 if "set" is not redefined in the source (maybe that's > already the case, haven't checked). I just took a peek at the source in cython-dev. I don't really understand what's happening in the file but Builtin.py seems to have some support for the set type. >> As a side note, how about making an adjustment to Cython that >> automatically handles the set type/sets module trick? > > Yes, it would be nice to have that. The idea would be to do the Set import > internally, to provide replacement implementations for the generated > PySet_*() calls that work at the Python level, and to enable that > machinery when the C compile-time Python version is Py2.3. However, that's > work that someone has to do. > > OTOH, this is a pure legacy feature for code that must run with Py2.3. I > guess people (including myself) can currently live with the little > performance impact regarding the set operations (which are fast anyway), > given the gain that their code runs unchanged in Py2.3. I wish I had the time and expertise for this. :( Would this work if put at the top of every file (dashes indicate indentation)? if not hasattr(__builtin__, "set"): ----from sets import Set as set or this try: ----set except NameError: ----from sets import Set as set It seems like there could be an issue with static typing using the imported Python class sets.Set (e.g. `cdef set foo`). I don't know enough about Cython to make a good guess on that one. -Aaron _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
