On Oct 2, 2008, at 2:45 PM, Lisandro Dalcin wrote:
> On Thu, Oct 2, 2008 at 5:58 PM, Dag Sverre Seljebotn
> <[EMAIL PROTECTED]> wrote:
>> My five cents: I'm -1 on making emulating later Python versions in
>> earlier ones in most cases, and definitely this one. We are
>> developing
>> Cython for the present and future, and Python 2.3 is starting to
>> belong
>> to the past.
>
> Me to, -1 on this...
Some stuff (for example buffers, the with statement, and the b"byte
string" syntax) I believe are worth backporting. Python 2.3 will
continue to be a target for us (at least) as long as it is a target
for NumPy.
Backporting builtins, however, I don't think is usually worth the
effort. If one wishes to use more advanced builtins in ones sources,
then one limits the platform it can run on. This is exactly like .py
files.
>> The Cython compiler should run under Python 2.3 and create Python
>> 2.3-compatible code, but that is different from backporting builtins
>> like "set".
>
> However, Cython-the-compiler should not fail with syntax error if you
> do 'cdef set s', right? This indicates that builtin module is being
> used in the Cython codebase, and that is a potential source of
> problem. In sort, I believe if you run Cython with python2.3, the
> generated source should be valid Py3 C code, even if something like
> 'set' is being used. I'm missing something here?
Let X <= Y. If you run Cython with Python X, then it should compile
against and run under Python Y. However, if you run Cython with
Python Y, it may not compile against or run under Python X (depending
on if you have used features introduced after X). Without backporting
every new feature back to 2.3, this is the best we can hope to do.
Letting set be defined no matter what violates this principle. Thus
if they have a Python 2.3 toolchain, they can (too easily) produce
code that they cannot use. Furthermore, the error will be some
obscure (to most people at least) message in the C compile. Much
better to raise an error during the Cython run. That way if Cython
succeeds, the C compile will succeed and the module will work (modulo
any bugs of course).
In this case I think Didier's original patch was the right approach,
though we will have to adjust the testing framework to account for
it. I might suggest that testing
import __builtin__
if hasattr(__builtin__, 'set'):
....
is a bit more intuitive than the test you had before.
- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev