Skip to content
Preptima

Python Memory & Performance interview questions

Reference counting, garbage collection, profiling, and where interpreter overhead dominates.

3 questions in Python.

medium2

mediumConceptCoding

A list of a million small objects uses far more memory than the data inside them. Where is it going?

Into per-object overhead: in CPython on a 64-bit build every object carries a 16-byte header, every field is itself a boxed object reached through an 8-byte pointer, and each instance has a dictionary. Slots remove the dictionary, and a columnar layout removes the objects. Use this memory layout answer to show the decision, trade-off, and evidence rather than a memorised definition.

5 minmid, senior, staff

hard1