I'm reluctant to working on adapting Cython during alphas, because it
happened more than once that incompatible changes in CPython were rolled
back or modified again during alpha, beta and rc phases. That means more
work for me and the Cython project, and its users. Code that Cython users
generate and release on their side with a release version of Cython will
then be broken, and sometimes even more broken than with an older Cython
release.
I don't have the capacity to follow all relevant changes in CPython,
incompatible or not.
I think the reason for this is that Cython is trying to be two
things at once: (1) an interface between Python and C, (2) a
compiler that turns Python code into fast C code.
To address this there could be an option to choose between
"compatible code" and "fast code", with the former restricting
itself to the stable API.
--
Greg
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/EACB7ZZVDDNL4QAIODYDNWLKI455QDKP/
Code of Conduct: http://python.org/psf/codeofconduct/
On 2/02/22 11:53 am, Christopher Barker wrote:
> As a long time Cython user, but not a Cython developer, I think (2) is
> the primary purpose, with (1) as a handy side benefit (otherwise
> we'd just use ctypes, yes?)
Personally, no, I would not "just use ctypes". The main reason I
created Pyrex was to avoid the extreme amounts of pain involved
in doing things like that.
> That being said a not-quite-as-fast-as-possible mode would be fine.
> Though I'm not sure it would buy much, as long as projects (including
> major ones like numpy) are using as-fast-as-possible mode.
That's why I think compatible mode should be the default. Then
those who choose otherwise will be aware of what they are doing.
Guido van Rossum schrieb am 02.02.22 um 00:21:
> I wonder if a solution during CPython's rocky alpha release cycle could be
> to default (either in Cython or in projects using it) to the "not quite as
> fast but not relying on a lot of internal APIs" mode, and to switch to
> Cython's faster mode only once (a) beta is entered and (b) Cython has been
> fixed to work with that beta?
This seems tempting – with the drawback that it would make Cython modules
less comparable between final and alpha/beta CPython releases. So users
would start reporting ghost performance regressions because it
(understandably) feels important to them that the slow-down they witness
needs to be resolved before the final release, and they just won't know
that this will happen automatically triggered by the version switch. :)
Feels a bit like car manufacturers who switch their exhaust cleaners on and
off based on the test mode detection.
More importantly, though, we'd get less bug reports during the alpha/beta
cycle ourselves, because things may look like they work but can still stop
working when we switch back to fast mode.
I'd rather make it more obvious to users what their intentions are. And
there is already a way to do that – the Limited API. (and similarly, HPy)
For Cython, support for the Limited API is still work in progress, although
many things are in place already. Getting it to work completely would give
users a simple way to decide whether they want to opt in for a) speed, lots
of wheels and adaptations for each CPython version, or b) less performance,
less hassle.
As it looks now, that switch can be done after the code generation, by
defining a simple C define in their build script. That also makes both
modes easily comparable. I think that is as good as it can get.
Guido van Rossum schrieb am 02.02.22 um 01:43:
Yes. HPy is certainly far from ready for anything real, but even for the
Limited API, it's still unclear whether it's actually complete enough to
cover Cython's needs. Basically, the API that Cython uses must really to be
able to implement CPython on top of itself. And at the same time interact
not with the reimplementation but with the underlying original, at the C
level. The C-API, and especially the Limited API, were never really meant
for that.
I agree. Shipping the generated C sources was a very good choice as long as
CPython's C-API was very stable and getting a build time dependency safely
installed on user side was very difficult.
These days, it's the opposite way.
Stefan
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/KTWDJGHPQW7AIKDQQYV4IFHAKQZVXACL/
Code of Conduct: http://python.org/psf/codeofconduct/
On 2 Feb 2022, at 11:50, Stefan Behnel <stef...@behnel.de> wrote:Petr Viktorin schrieb am 02.02.22 um 10:22:Moving off the internal (unstable) API would be great, but I don't think Cython needs to move all the way to the limited API.
There are three "levels" in the C API:
- limited API, with long-term ABI compatibility guarantees
That's what "-DCYTHON_LIMITED_API -DPy_LIMITED_API=..." is supposed to do, which currently fails for much if not most code.- "normal" public API, covered by the backwards compatibility policy (users need to recompile for every minor release, and watch for deprecation warnings)
That's probably close to what "-DCYTHON_LIMITED_API" does by itself as it stands. I can see that being a nice feature that just deserves a more suitable name. (The name was chosen because it was meant to also internally define "Py_LIMITED_API" at some point. Not sure if it will ever do that.)- internal API (underscore-prefixed names, `internal` headers, things documented as private)
AFAIK, only the last one is causing trouble here.
Yeah, and that's the current default mode on CPython.
Maybe we should advertise the two modes more. And make sure that both work. There are certainly issues with the current state of the "limited API" implementation, but that just needs work and testing.
Stefan
_______________________________________________
Python-Dev mailing list -- pytho...@python.org
To unsubscribe send an email to python-d...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/ESEPW36K3PH4RM7OFVKAOE4QMBI2WYVU/
Code of Conduct: http://python.org/psf/codeofconduct/
Maybe we should advertise the two modes more. And make sure that both work.
Message archived at https://mail.python.org/archives/list/pytho...@python.org/message/P7SMK5ZGFAHZMLUKW4WZNNX47CONXIQS/
Code of Conduct: http://python.org/psf/codeofconduct/
Code of Conduct: http://python.org/psf/codeofconduct/