5 Re-implementing critical code with Cython

This chapter covers

  • How to re-implement Python code more efficiently
  • Understanding Cython from a data processing perspective
  • Profiling Cython code
  • Using Cython to implement performant NumPy functions
  • Releasing the GIL to implement true threaded parallelism

Python is slow. The standard implementation is slow, and the language’s dynamic features pay a performance toll. Many Python libraries are performant precisely because they are partially implemented in lower-level languages, making available efficient data processing algorithms. But sometimes we will need to implement our own high-performance algorithms in something faster than Python. In this chapter, we will consider Cython, a superset of Python ...

Get Fast Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.