C++ ♥ Python
summary
Compares concrete bindings and benchmarks: looped Python sum is ~4× slower than built-in sum; NumPy sum on native NDArrays runs 21× faster than Python but suffers huge copy overhead when fed Python lists; PyTorch moves big tensor multiplies from ~40s on CPU to 0.047s on GPU but PCIe copy back makes end-to-end 31s; naïve pybind11 bindings add seconds of overhead (C++ 4ms vs pybind11 5s) unless batched and using NumPy buffers; CPPYY runs C++ via cling dynamically and avoids binding boilerplate while matching native performance.
AI-written summary · about
chapters (13)
- 0:00Introduction and background
- 1:53Surveying language usage
- 4:37Python's appeal
- 5:58Modern C++ and Python
- 9:45Risks of interpreted code
- 15:48Mitigating Python risks
- 19:31Optimizing Python performance
- 25:33AI models with PyTorch
- 29:00Extending CPython
- 34:31Static binding tools
- 43:30Cython and integration
- 51:05Dynamic binding with cppyy
- 56:52Q&A and closing
