Serdar Yegulalp
Senior Writer

Cython 3.0: The next generation of Python at the speed of C

news
Jul 17, 20232 mins
C LanguageDevelopment Libraries and FrameworksPython

Long in development, the new major release of the Python-to-C compiler sheds legacy Python support and readies Cython developers for big changes in Python.

High-speed train tunnel / motion blur / speed / motion / forward progress / future / what's next

The developers behind Cython, the Python library for compiling Python code to C, have at last released Cython 3.0 after many years of development and refinement.

The main goal behind Cython is to make it easier to write C extensions for Python, whether for speed or to author convenient interfaces to C libraries. In many ways Cython 3 cleans up and modernizes Cython. Itย drops support for the long-obsolete Python 2, adds support for newer Python features (up to Python 3.12), and expands the use of โ€œpure Python mode.โ€

Pure Python mode allows Python developers to use their existing Python linting and code analysis tools on Cython.ย Historically, Cython used its own peculiar syntax, a hybrid of Python syntax and the C type declaration syntax, which made Cython hard to troubleshoot with Python tooling.ย Over time Cython began offering an alternative syntax that was fully compatible with conventional Python syntax, called pure Python mode. The vast majority of Cython functions are now exposed inย pure Python mode, including functions forย calling external C libraries.

Another major area of improvement is NumPy support. Cython has long played well with NumPy, allowing you to write Cython functions that hook directly and natively into NumPy functions and data structures. Cython 3 adds (among other things) the ability to write NumPy ufuncs directly in Cython, so that a simple numerical function written in Cython can be quickly and easily applied to the entire contents of a NumPy data structure.

Cythonโ€™s internals have also been reworked to better complement the ongoing changes to Pythonโ€™s internals. The new โ€œlimited APIโ€ for Python, for instance, exposes a guaranteed stable subset of Pythonโ€™s APIs, specifically for the kind of work Cython often does to hook into the Python interpreter. Cython 3 has preliminary but growing support for the limited API.ย In the long run, this means Cython extension modules built for one version of Python will work in future versions of Python without needing to be recompiled.

The first releases of Cython 3 emerged alongside Python 3.8 three years ago. No firm date or version target was set for when Cython 3 would be finalized. But Cythonโ€™s development team encouraged wide use of the alpha and beta versions of Cython 3, andย the project has kept pace with new features and internal changes in every version of Python along the way.

Serdar Yegulalp

Serdar Yegulalp is a senior writer at InfoWorld. A veteran technology journalist, Serdar has been writing about computers, operating systems, databases, programming, and other information technology topics for 30 years. Before joining InfoWorld in 2013, Serdar wrote for Windows Magazine, InformationWeek, Byte, and a slew of other publications. At InfoWorld, Serdar has covered software development, devops, containerization, machine learning, and artificial intelligence, winning several B2B journalism awards including a 2024 Neal Award and a 2025 Azbee Award for best instructional content and best how-to article, respectively. He currently focuses on software development tools and technologies and major programming languages including Python, Rust, Go, Zig, and Wasm. Tune into his weekly Dev with Serdar videos for programming tips and techniques and close looks at programming libraries and tools.

More from this author