Python 103: Mmmm... Understanding Python's Memory Model, Mutability, and Methods
summary
Explains why Python passes object references and how mutability changes observable behavior, demonstrates CPython’s reference counting plus a cycle detector and the undocumented small-int interning up to 256, shows pitfalls with aliasing vs shallow copies and how copy.deepcopy fixes them. Builds a Time60 class with __str__ and __add__ that normalizes minutes to hours (works in examples). Gives performance tips using timeit, caching repeated len()/func calls, describes list growth (amortized doubling then tapering) and recommends collections.deque for fast pops/pushes at both ends.
AI-written summary · about
chapters (6)
- 0:00Start
- 1:58How I Got Started
- 23:23Special Methods
- 1:11:59Memory Allocation
- 1:14:58Shrinking
- 1:15:50Double Ended Queue
related talks
23mMemoirs of a Python Object: Memory Management and Improving Performance
23mPython Memory Understanding
25mIs it me or Python memory management? 🤔💻
31mPlaying with CPython Objects Internals
27mVariables and objects in Python: it's pointers all the way down
27mPython Oddities Explained
27mDemystifying Python’s Generational Garbage Collector
31mIntroducing Immortal Objects: Building Block Towards a Multi-core Python Runtime
