Cython 3 Released |
Written by Mike James |
Tuesday, 18 July 2023 |
Cython 3.0, the latest release of the Python library that can be used to compile Python code to C, has been released with improvements including support for recent versions of Python, easier working with NumPy, and reworking to support Python's 'limited' API. Cython is a Python implemenation that makes writing C extensions for Python as easy as Python itself. It is based on The developers say that Cython 3.0.0 has been a very large effort that cleaned up many old warts, introduced many new features, and introduces a couple of intentional behavior changes, even though the goal remained to stay compatible as much as possible with Cython 0.29.x. Retaining compatibility with Python is a major part of the update, as CPython versions 3.8-3.11 were released while Cython 3 was under development. All these versions are supported in Cython, including experimental support for the in-development CPython 3.12. Cython interacts very closely with the C-API of Python, and this is where most of the adaptation work happens, according to the developers. Work has also been carried out so that Cython can parse newer Python constructs for use with its pure python mode. The new release has also added support for non-ASCII identifiers so that developers writing in a language that uses non-ASCII letters can use them in identifiers. It also has simplified customisation of class creation to avoid the need to use a custom metaclass. Other improvements include support for positional-only parameters and for assignment expressions (a.k.a. the walrus operator :=). Initial support has been added for CPython's so-called Limited API. This is a stable, limited subset of CPython's C-API that comes with the guarantee of a stable ABI, meaning that extensions modules that were compiled for one version of CPython can also be imported in later versions without recompilation. There is now initial support for this in Cython with an option to cut down on Cython's C-API usage to adhere to the Limited C-API. The developers say some advanced Python features (like async code) may lead to C code that cannot adhere to the Limited C-API, or where Cython simply does not know yet how to adhere to it. NumPy support has also been improved so that you can write NumPy ufuncs directly in Cython. Cython 3 is available now.
More InformationRelated ArticlesCython is 20 - Why Is It Ignored? Guido And Microsoft Want To Make Python x2 Faster Pyston 2.2 Goes Open Source Again To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info <ASIN:1871962749> <ASIN:1871962757> <ASIN:1871962765> <ASIN:187196282X> |
Last Updated ( Tuesday, 18 July 2023 ) |