Sobes.tech
Junior — Middle

Which data type uses less memory: mutable or immutable?

sobes.tech AI

Answer from AI

Immutable data types in Python (such as strings, tuples, numbers) generally occupy less memory than mutable ones (such as lists, dictionaries) because immutable objects are optimized for storage and can be reused (for example, string interning). Mutable objects often contain additional metadata to support modifications, which increases their memory footprint. However, the exact size depends on the specific implementation and data structure.