Python Strings, Explained and Benchmarked Across 3 CPython Versions
Python strings explained and benchmarked on CPython 3.8, 3.10, and 3.12: immutability, slicing, f-string vs .format() speed, the += refcount trap, and PEP 393 memory.
Python strings explained and benchmarked on CPython 3.8, 3.10, and 3.12: immutability, slicing, f-string vs .format() speed, the += refcount trap, and PEP 393 memory.
Python objects cost 56 to 282 bytes each depending on how you store them. A benchmark on CPython 3.10.12 shows __slots__ cutting memory 47.9%.
Python variables are names bound to objects, not boxes. Benchmarks map the LEGB read-speed ladder, the small-int is cache, aliasing, and the mutable-default trap.
Python lists with real benchmarks: the 11 methods, insert(0)’s 264x penalty, list vs set vs deque vs array, copying, sorting, and how the list works under the hood.