Robert Bradshaw, 15.03.2010 17:48:
>> 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
Note that I already disabled typing in function signatures (to let users
write code like "def func(int)"), so there are only a couple of other
places left to fix that will not interfere that easily anymore.
> and the idea of leveraging the Python parser is an interesting one.)
It's a lot more work, though, given that all work that you put into
Cython's parser automatically extends the Cython language to match Python
better, whereas using CPython's parser will only work as an alternative to
Cython's own parser, given how smart Cython's parser still is.
>>> 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.
That sounds like a case for a "cython3" script, as well as a general switch
for the distutils Extension, e.g.
cython_language_level="3"
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev