Series

Inside the interpreter

What CPython actually does with the objects, modules and threads you hand it — measured on a real interpreter rather than argued from the docs.

In reading order · 4 entries

  1. Part 1

    The Shape of a Python Object

    An instance with three attributes costs 96 bytes, not the 344 sys.getsizeof reports, and __slots__ read 12% slower on the CPython 3.13.2 build measured here.

  2. Part 2

    What import Actually Does

    Importing asyncio costs 21.9 ms and pulls in 100 modules. Importing email costs 0.1 ms and pulls in one. Granularity predicts import cost; size does not.

  3. Part 3

    The GIL Is Not a Lock on Your CPU

    Eight threads of pure-Python arithmetic run at 0.98x the speed of one. The same eight threads doing IO run at 7.90x. The GIL is a scheduler, and it has a dial.

  4. Part 4

    Slots Did Not Get Slower, One Build Did

    A read through __slots__ costs 24% more than one through an instance dictionary on CPython 3.13.2. Rebuild the same version and the gap goes away.

Arrow keys to move, Enter to open.