Python objects carry overhead that surprises people who come from other languages: even an empty object has a header, and a list does not hold its items but pointers to them. This lesson shows how to measure size, what makes some objects smaller, and the two ways that CPython saves memory and time by sharing objects: caching small integers and interning strings. It ends with a warning about is, which these tricks make look more reliable than it is.
More lessons in Complete Python Programming