On Mar 14, 2010, at 6:23 AM, Stefan Behnel wrote:

> Robert Bradshaw, 13.03.2010 21:07:
>> On Mar 13, 2010, at 5:30 AM, Stefan Behnel wrote:
>>> b) compatibility with Py3 code (->  .py files + "-3" option or
>>> "cython3")
>>> [...]
>>> with the obvious gray area of future imports between a)/c) and b).
>>>
>>> We don't currently care about the file extension, for example.
>>> Should we generally stop supporting the 'cdef' keyword in .py files?
>
> I disabled all Cython specific keywords when compiling .py files.
>
> http://hg.cython.org/cython-devel/rev/198e42d128dd

Cool. As Greg pointed out, this may not be everything, but I bet  
this'll handle 95% of what's there. (The other 10% will be harder, and  
the idea of leveraging the Python parser is an interesting one.)

>> The -3 option would be completely orthogonal to the file extension,
>> and could be used with both .py and .pyx files.
>
> Actually, I'd even prefer having it a top-level compiler directive  
> instead
> of a command line switch. If a source file is written in Py3 syntax,
> there's no use in making it optional to compile it as Py2 code and  
> vice
> versa. So putting
>
>     # cython: python3=True
>
> at the top is a lot safer and simpler. Maybe we could even be smart  
> and
> pick up a shebang line like
>
>     #!...python3
>
> as Python 3.x installs its interpreter as 'python3' by default, but  
> I guess
> that's hard to do reliably.

We should certainly have a dirctive. One advantage of a first-level  
command line option is that I would guess it would be a more global  
option (i.e. it will probably be most common for people will have all  
or no Py3 files, or none, except during a possible transition phase)  
and I imagine eventually the default will be switched.

- Robert

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

Reply via email to