Stefan wrote:
> Hi,
>
> Lisandro Dalcin wrote:
>> Iff the 'from __future__ ...' is NOT used, and a in a pxy file I do
>>
>> a = "abc"
>>
>> What the type of 'a' will be if I compile and run the generated C
>> source in a Python 3 runtime environment?
>
> I'm currently reconsidering that, and I'm still not sure. We could simply
> enable all __future__ features by default that the runtime environment
> enables
> (and that we support in Cython, obviously). That's a straight forward
> thing to
> do and it wouldn't be any different from the portability of Python code...
>
> What do the others think?

I think:

- The default "Python language level" for the pyx source when Cython is
run should be that of the interpreter Cython is launched within. I.e, if
cython.py is launched in Python 2.6, then "from __future__ import with" is
enabled by default (to take one example that I know about). I think this
is most likely to match user expectations.

Command-line switches to Cython should be able to override this though.

- Once compiled to C...the nice, explicit thing to do would be that once
it hits C level, the module acts externally in the same way (same types of
objects are created) no matter the C compilation environment.

This means that if you have a pyx file, and you want the exact same
non-conditional source to give old-style str in Python 2 and new-style str
in Python 3, you have to invoke cython twice with different command-line
arguments and create two C files (basically, the pyx means different
things each time it is compiled, as different language levels are enabled
for it each time). I think one can live with that, people should just use
unicode everywhere anyway.

But this is something I'm not sure of :-)

Dag Sverre

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to