~/talk

Under the Hood of Python Data Structures

Talkat PyCon Italia 2025 · 2025-05-28..05-31· [compilers-and-language-design]
links:none on file
slides:none on file

CPython source code and quick REPL experiments show lists as contiguous dynamic arrays that overallocate (~12.5%) using a shift-and-round formula when append is called (avoiding frequent reallocations), integers are cached for -5..256 (small-int cache -5..256), dicts start with eight index slots and use a separate entries table plus quadratic probing for collisions, sets are hash-only dicts, and tuples are single contiguous allocations and hashable when elements are. Empirical timings confirm dict/set lookup O(1) vs list linear scans; preallocation improves append-heavy cases.

AI-written summary · about

  1. 0:00Introduction to Python internals
  2. 1:28Python implementation overview
  3. 3:40Compiled vs interpreted languages
  4. 5:04Variables and memory references
  5. 7:11Mutability in Python objects
  6. 9:21How lists are implemented
  7. 14:30Hash functions and hash tables
  8. 18:45Dictionaries in Python
  9. 20:29Sets and their implementation
  10. 21:53Performance of data structures
  11. 22:33Learning from Python internals
  12. 23:56Q&A session
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.