Chapter 4: C Performance with Cython
Cython is a language that extends Python by supporting the declaration of types for functions, variables, and classes. These typed declarations enable Cython to compile Python scripts to efficient C code. Cython can also act as a bridge between Python and C as it provides easy-to-use constructs to write interfaces to external C and C++ routines.
In this chapter, we will learn about the following topics:
- Compiling Cython extensions
- Adding static types
- Sharing declarations
- Working with arrays
- Using a particle simulator in Cython
- Profiling Cython
- Using Cython with Jupyter
Through this chapter, we will learn how to leverage Cython to improve the efficiency of our programs. While a minimum knowledge of C is helpful, this chapter focuses only on Cython in the context of Python optimization. Therefore, it doesn't require any C background.