Picking the right data type in Python starts with the basics. In Part 1 of Python’s data types, we cover NoneType, bool, int, float, and complex.
Working with many objects at once requires the right container. In Part 2 of Python’s data types, we cover str, bytes, tuple, list, bytearray, set, and frozenset.
In Part 3 of Python’s data types, we cover dict and the new frozendict, Python 3.15’s built-in immutable mapping, plus how to choose the right data type for the job.
In Python, two variables equal to 256 share the same object, but two variables equal to 512 don’t. The reason is Python’s object model. In this chapter, we cover identity, type, and value; how assignment and name binding actually work; the small-integer cache; and why mutating a list changes both aliases while reassigning a string doesn’t.