Cython in Practice: A Deep Dive into Legacy C Integration and Debugging
summary
Cython wrapper for the Triangle C library compiles to under a thousand lines and ultimately runs on Linux Mac Windows after fixing concrete issues: an unsigned long size mismatch (4 vs 8 bytes) is changed to unsigned long long, pointer aliasing that causes double frees is replaced by copying, and holes/regions buffers are reallocated correctly. Runtime stepping uses GDB; memory corruption and invalid read/writes are diagnosed with Valgrind. Packaging uses Poetry then CI-built manylinux wheels with a uV/scikit-build workaround.
AI-written summary · about
chapters (11)
- 0:00Cython and legacy C
- 3:55Triangle library wrapper
- 7:44Cython conventions and types
- 10:51Memory corruption on Windows
- 13:43Valgrind for memory errors
- 16:55Data type compatibility
- 18:23Double-free memory errors
- 20:49Packaging with Poetry
- 22:57UV and scikit-build-core
- 24:00Key takeaways
- 25:22Q&A
related talks
33mA low latency deepdive of Python with Cython
40mGet native with Cython
31mCFFI, Ctypes, Cython The Good, The Bad and The Ugly
33mEasy wins with Cython: fast and multi-core
42mLift your Speed Limits with Cython
39mPushing Cython to its Limits in Scikit-learn
31mUnderstanding Python from the inside: C concepts to dive into CPython fearless
01h 03mA tour of CPython's runtime
