Pyベンチ実測MEASURED, NOT RECALLED

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

    index 参照 is ~1.54× slower than 直接イテレート

    Iterating directly is ~1.5× faster than indexing with `range(len(xs))`.

    Result

    Runindex 参照直接イテレートRatio
    Run 15.4033.4721.56×
    Run 25.3483.5321.51×
    Run 35.3223.4441.55×

    Spread over 3 runs: index 参照 CV 0.6% / 直接イテレート CV 1.1% / Ratio CV 1.2%

    5.40 ms3.47 msRun15.35 ms3.53 msRun25.32 ms3.44 msRun3index 参照 (#b9c6d2) / 直接イテレート (#2f6f4f)

    Conditions

    Summing a 100,000-element list.

    Where this number does not apply

    If you need the index (neighbours, in-place writes), direct iteration is not an option.

    Reproduce

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