Pyベンチ実測MEASURED, NOT RECALLED

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

    enumerate is ~1.45× slower than range(len())

    `enumerate` is ~1.5× faster than `range(len(xs))` because it avoids indexing.

    Result

    Runrange(len())enumerateRatio
    Run 15.3537.8620.68×
    Run 25.2957.7470.68×
    Run 35.5337.6780.72×

    Spread over 3 runs: range(len()) CV 1.9% / enumerate CV 1.0% / Ratio CV 2.6%

    5.35 ms7.86 msRun15.30 ms7.75 msRun25.53 ms7.68 msRun3range(len()) (#b9c6d2) / enumerate (#2f6f4f)

    Conditions

    Walking 100,000 elements while using both index and value.

    Where this number does not apply

    Reverse or step iteration still needs an index.

    Reproduce

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