Category 01
Runtime
What CPython does with the objects, modules and frames you hand it — object layout, the import system, the eval loop, memory behaviour.
- Entries
- 6
- Series
- 2
lazy import Moved 26.8 ms and Removed None of It
A lazy import of asyncio costs no measurable time and no modules at startup. Read the name once and 26.4 of the 26.8 ms come back. Deferral is not removal.
A NamedTuple Read Cost 0.81x a Plain One, Then 1.9x
On CPython 3.10 a NamedTuple attribute read cost 0.81x a read through an instance dictionary. On 3.11 it costs 1.90x. Nothing about NamedTuple changed.
getsizeof Reports 296 Bytes, Then 96, for the Same Class
sys.getsizeof reports 296 bytes for a class's first instance dict and 96 once twenty-six exist. The instance itself costs 96 bytes and getsizeof says 48.
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.
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.
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.