[Cython] Should we start requiring "language_level=2" for .pyx files?

Erik Bray erik.m.bray at gmail.com
Thu May 31 10:35:04 EDT 2018


On Mon, May 28, 2018 at 8:56 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> Hi,
>
> Python 3 is clearly taking over the world these days, so it starts feeling
> arcane to require Py2 syntax in .pyx files. Increasingly, it means that
> people cannot just rename .py files anymore to start optimising them,
> because the .py file has a high chance of being written in Py3 syntax.
>
> Eventually, we will have to switch to Py3 syntax by default in order to
> follow what most people are (or will be) used to.
>
> As a transition, I think we could start warning about cases where the
> language level is not set explicitly. If people start marking their code as
> being "Cython 2.x code", either with an in-file directive or from their
> setup.py, we will have less of a problem in the future to change the default.
>
> What do you think? Any other ideas, comments, objections?


Perhaps you could clarify something:  I tried suggesting a while ago
that Sage start using language_level=3 at least when actually building
Sage on Python 3.  I know this isn't necessary but it just seemed to
make logical sense.  But Jeroen was convinced it wasn't necessary
because, according to him, language_level=3 doesn't really do
anything.

So what exactly does language_level=3 (or 2) do, such that it would
impact porting Python 3 code to Cython?


More information about the cython-devel mailing list