Professional Documents
Culture Documents
Key Search Is Very Fast: "Saving Space With The - Slots - Class Attribute" On Page 264
Key Search Is Very Fast: "Saving Space With The - Slots - Class Attribute" On Page 264
attributes from a dict to a tuple in each instance. This will be discussed in “Saving Space
with the __slots__ Class Attribute” on page 264 (Chapter 9).
Keep in mind we are talking about space optimizations. If you are dealing with a few
million objects and your machine has gigabytes of RAM, you should postpone such
optimizations until they are actually warranted. Optimization is the altar where main‐
tainability is sacrificed.
d1 = dict(DIAL_CODES)
print('d1:', d1.keys())
d2 = dict(sorted(DIAL_CODES))
WOW! eBook
www.wowebook.org