~/talk

Python Memory Deep Dive for Speed and Efficiency

Talkat Python Web Conf 2021 · 2021-03-22..03-26· [python]
slides:none on file

CPython uses reference counting plus a generational GC (small objects <=512 bytes are pooled by pymalloc), so memory behavior depends on allocators and object topology rather than just types. Use sys.getsizeof and a recursive sizeutil.get_full_size to measure real cost, tune gc with gc.get_threshold / gc.set_threshold (default gen0 = 700), prefer generators over lists to cut peak RAM (demo goes ~335MB → ~124MB), reuse/overwrite locals to free memory earlier, and large workloads can drop collections (example sitemap: 77 → 2) and speed up tests.

AI-written summary · about

  1. 0:00Introduction to Python memory
  2. 1:06Python memory as black art
  3. 3:12C pointers vs Python references
  4. 8:48Object sizes and memory overhead
  5. 14:21Python memory allocation layers
  6. 21:22Reference counting in Python
  7. 28:46Garbage collection cycles
  8. 37:42Memory optimization techniques
  9. 45:30Summary and Q&A
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 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
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
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.