Reducing your memory footprint by 75% with 6 lines of code
summary
Claims a 75% memory reduction and large runtime and startup wins by changing a few lines where AbstractBaseClass checks cause massive recursive subclass and instance probing. Uses cProfile, a flame chart and a memory profiler to find millions of tiny allocations (11M allocations, ~1.8GB in a 12s run) traced to abc.ABCMeta __subclasscheck__/__instancecheck__ work. Replacing the expensive check with direct registration/shortcut logic (six to eight lines) eliminates the allocations and fixes the leak.
AI-written summary · about
chapters (10)
- 0:00Introduction and confession
- 2:25Identifying the performance problem
- 4:16Types of profilers
- 7:15Analyzing slow function calls
- 11:38Memory leaks and profiling
- 14:14Investigating the bug
- 16:56Abstract base classes and registration
- 18:44The fix and its impact
- 20:11Results and benefits
- 20:37Q&A session








