Annotations and Cython 3
I suspect the answer to this is still "wait and see" but: do we have an opinion on what we want to do about annotations in Cython 3. Currently we're targetting PEP-563 behaviour. To me it looks fairly likely that this won't be what Python decides on. I guess the likely outcomes are "status quo" or something close to PEP-649. The issue with the PEP-563 (stringify everything) behaviour is that it's noticeably different, so releasing Cython 3 with that behaviour then changing to something else will be an obvious incompatible change. I'd be reluctant to implement PEP-649 until it's actually accepted (it looks hard...). Is it worth reverting to the Cython 0.29 behaviour (with some scoping fixes) on the basis that it's what most people are using now, and it's likely to be closer what what's picked? Or should we at least mark "decide what to do with annotations" as a blocker for Cython 3? David
One further option would be to revert to Cython 0.29 behaviour, but support the PEP-563 version as a "from __future__" import (essentially following the current behaviour of Python). When I wrong the original patch for the PEP-563 I tried to do that, but then removed the code in favour of keeping one simpler option. But the code to do this mostly already exists (somewhere) On 25/10/2021 19:11, da-woods wrote:
[...]
On Mon, 25 Oct 2021 at 21:57, da-woods <dw-git@d-woods.co.uk> wrote:
One further option would be to revert to Cython 0.29 behaviour, but support the PEP-563 version as a "from __future__" import (essentially following the current behaviour of Python).
In any case, if you know how and can implement the __future__ import, that would be great. Otherwise, valid Python3 code using that import currently fails to compile in Cython. In addition, perhaps you should consider adding a compiler directive (or there is one already that I'm missing?) that we can pass with -X o type as a #cython comment in sources. In the face of ambiguity... give users various alternatives to the control the behavior. -- Lisandro Dalcin ============ Senior Research Scientist Extreme Computing Research Center (ECRC) King Abdullah University of Science and Technology (KAUST) http://ecrc.kaust.edu.sa/
Am 26. Oktober 2021 07:54:10 MESZ schrieb Lisandro Dalcin:
In any case, if you know how and can implement the __future__ import, that would be great. Otherwise, valid Python3 code using that import currently fails to compile in Cython.
Probably just an oversight. A no-op future import is trivial to add and ignore.
In addition, perhaps you should consider adding a compiler directive
There is one (annotation_typing) that controls whether Cython reads annotations as types or not (which isn't what you're asking for). Apart from that, since there is no future unimport, there should probably be a way to get either behaviour, regardless of the default. Stefan
On 26/10/2021 07:53, Stefan Behnel wrote:
Am 26. Oktober 2021 07:54:10 MESZ schrieb Lisandro Dalcin:
In any case, if you know how and can implement the __future__ import, that would be great. Otherwise, valid Python3 code using that import currently fails to compile in Cython. Probably just an oversight. A no-op future import is trivial to add and ignore.
We do support the __future__ import as a no-op on the Cython 3 alphas: https://github.com/cython/cython/blob/e93c2c556c5c15148763b26c6e3eef35ee88a2...
participants (3)
-
da-woods -
Lisandro Dalcin -
Stefan Behnel