[Cython] cython doesn't compile cdef'd variables of type set?
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Fri Oct 3 12:18:55 CEST 2008
Dag Sverre Seljebotn wrote:
> Robert Bradshaw wrote:
>> 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.
>
> I don't follow the logic here.
>
> Please bear with me, this is important: One consequence is that there is
> currently no way to get access to Py3-only builtins from pyx files
> without using getattr (like "memoryview", unless it was added to
> Python2.6 last minute, I didn't fetch the release yet. But even if it
> was, I don't think there's any rule that all new Python 3.x builtins
> will be backported to 2.x?).
>
> In my mind there's three different Python versions involved:
>
> - A: The version of Python the user targets in the pyx file (when it
> comes to library and builtins; keeping the language part out of this).
> - B: The version of Python that imports the compiled module. The user
> just has to make sure that this matches A in a reasonable fashion (the
> rules are non-trivial and not a simple >= or <=, as Py3 removes
> builtins, but Python lays these down for us).
> - C: The version that runs Cython.
>
> This discussion was about A and B -- that Cython won't allow users to
> code for Py2.4 and run under Py2.3.
>
> You seem to be talking about C, which is something different. Cython
> just transforms code and could run on any Turing-machine, there's no
> natural reason it has to be connected with A or B.
>
> We do currently require C >= B (which means that any Py3-only builtins
> are plain unavailable).
>
> In my opinion, ideally C should be orthogonal to A and B because that
> seems to be less complicated from a release and bugfinding perspective
> (one less version to worry about in the mix) and it would fix the issue
> with accessing Py3-builtins for free, but I don't care very much.
To be more concrete, the problems you mention could be fixed with a
simple compiler flag (or directive) to Cython: --target-platform=3.0 or
similar, to control the builtins. But, "there's no lack of good ideas".
--
Dag Sverre
More information about the Cython-dev
mailing list