I'm working on LunarDump v0.4 and taking the opportunity to learn more about Cython and how it can bring Python code closer to native performance. I'm particularly interested in using it for performance-sensitive areas such as chunking, buffering, compression, and encryption. I'm still experimenting and would like to understand what kind of speedup is realistic. LunarDump v0.5 may use Cython for some critical functions. What books, courses, documentation, or video resources would you recommend for learning Cython?
3 Answers
Start with the official Cython documentation. It tends to stay more current than books, and it covers the important concepts: type annotations, extension types, compiler directives, memoryviews, and calling C or C++ code. Benchmark each change, since moving code to Cython does not automatically make every function faster.
Before committing to Cython, compare it with writing only the hotspots in C or C++ and exposing them to Python. That is the general approach used by many high-performance numerical libraries. Profiling first will help you avoid rewriting code that is not actually limiting performance.
It is also worth evaluating newer binding options, especially Rust with PyO3 or C++ with tools such as nanobind. They can provide strong type and thread-safety guarantees and may offer better tooling for a new extension. Cython is still useful for gradually optimizing existing Python code, but it is not the only practical choice anymore.

That approach makes sense when the algorithm already maps cleanly to C or C++, though Cython can be convenient when you want to keep much of the implementation close to Python.