A low latency deepdive of Python with Cython
summary
Benchmarks compare raw Python to compiled Cython: microbenchmarks use Intel pmu counters and generated C to measure instruction counts (adding two ints costs ~528 CPU instructions in untyped Python). Replacing Python objects with C types and a memory view yields ~30× speedup (random access down to ~180 ns), moving the loop into Cython removes ~150 ns per Python-call overhead, and a fully typed, nogil inner loop reaches single‑digit nanoseconds (~5 ns) with correct behavior.
AI-written summary · about
chapters (9)
- 0:00Python performance with Cython
- 2:12CPython interpreter internals
- 8:36Python ops baseline
- 11:24What Cython is
- 14:19Python vs Cython microbenchmarks
- 18:17When to use Cython
- 19:02Optimizing data frame lookups
- 25:08Performance benchmarks summary
- 26:13Q&A on Cython, Rust, latency
related talks
42mLift your Speed Limits with Cython
33mEasy wins with Cython: fast and multi-core
40mGet native with Cython
31mCFFI, Ctypes, Cython The Good, The Bad and The Ugly
01h 21mAccelerating Python With C++
57mPython and PyPy performance (not) for dummies
22mPyPy and the future of the Python ecosystem
33mWhy is Python slow?
