Pyベンチ実測MEASURED, NOT RECALLED

    ↑↓ to select, Enter to open, Esc to close

    dict の参照 is ~1.12× slower than __slots__ 属性

    Attribute access on a `__slots__` class is ~12% faster than a dict key lookup.

    Result

    Rundict の参照__slots__ 属性Ratio
    Run 127.52224.7131.11×
    Run 226.64723.9441.11×
    Run 327.03724.0731.12×

    Spread over 3 runs: dict の参照 CV 1.3% / __slots__ 属性 CV 1.4% / Ratio CV 0.4%

    27.52 ms24.71 msRun126.65 ms23.94 msRun227.04 ms24.07 msRun3dict の参照 (#b9c6d2) / __slots__ 属性 (#2f6f4f)

    Conditions

    500,000 simple lookups.

    Where this number does not apply

    A 12% gap is small enough that design reasons should win.

    Reproduce

    cd bench && python micro_py.py --out ../data/run.json --samples 21