Optimizing Code Performance for Python Internals
summary
Shows concrete CPython internals that affect speed: CPython 3.10 uses a faster lookdict_unicode path for string-only dicts but inserting a non-string key or deleting a slot permanently falls back to the slower path; instance attribute key-sharing dicts (split dicts) save memory and CPU but adding attributes conditionally or deleting them disables sharing until the interpreter restarts; globals use inline caches with a 64-bit dict versioning counter (cache flushes slow code ~1.5x); CPython 3.11 gives ~1.5–1.7x speedups and 3.13 aims for ~4x.
AI-written summary · about
chapters (6)
- 0:00Introduction to Python internals
- 4:41Dictionaries performance basics
- 12:53Dictionary structure deep dive
- 25:52Global variables and inline caches
- 37:48Future of CPython optimizations
- 40:34Key takeaways and Q&A
related talks
32mWriting performant code for modern Python interpreters
25mAdvanced Python
29mHow we are making CPython faster. Past, present and future.
01h 03mA tour of CPython's runtime
33mA low latency deepdive of Python with Cython
17mCache me if you can: Boosting performance with Data Caching in Python
29mUnder the Hood of Python Data Structures
50mMeasuring the performance of CPython
