Top 3 Slots Interview Questions
Browse 3 real-world technical and behavioral interview questions about Slots. Review scenarios, edge cases, and architectural best practices.
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.
What is a descriptor, and how does @property use one?
A Python descriptor implements __get__, and optionally __set__ or __delete__, to control attribute access; @property is a data descriptor that wins over the instance dictionary.
A long-running Python service keeps climbing in memory and never comes back down. How do you work out where the memory went?
CPython frees an object the instant its reference count reaches zero, so steady growth is usually something still holding a reference rather than a leak. The cycle collector reclaims only reference cycles. Measure with tracemalloc first, then use __slots__ or generators to cut per-object and peak cost.