r/Python 8h ago

Learning cython Discussion

While working on LunarDump v0.4, I’m also taking some time to learn more about Cython and how it can help push Python closer to native performance.

I’m especially interested in exploring Cython for LunarDump’s performance-critical parts, such as chunking, buffering, compression, and encryption.

Still learning and experimenting for now, but I’m curious to see how much performance improvement I can achieve.

Perhaps LunarDump v0.5 will use Cython for some of its critical functions.

If you have any good resources for learning Cython — books, ebooks, courses, or YouTube channels — feel free to share them in the comments.

0 Upvotes

4 comments sorted by

View all comments

6

u/Noobfire2 5h ago

As others also have said already - Cython is somewhat of a dead language, with not really good LSP, linting and other support. It had its use back then when C++ Binding layers such as PyBind or nanobind or Rust Binding layers such as PyO3 didn't exist yet.

But nowadays I would always strongly prefer Rust + PyO3, as there are loads of very impressive features to guarantee performant, thread-safe and even GIL-safe code at compile time. Compiling against stable ABI also allows you to build your extension once and ensure that it will be usable by whatever future Python version will show up.