Pyベンチ実測MEASURED, NOT RECALLED

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

    deepcopy is ~37.04× slower than copy(浅い)

    Even for a nested dict, `copy()` (shallow) is ~37× faster than `deepcopy()`.

    Result

    Runcopy(浅い)deepcopyRatio
    Run 117.365654.6670.03×
    Run 217.536669.3480.03×
    Run 317.685659.7180.03×

    Spread over 3 runs: copy(浅い) CV 0.7% / deepcopy CV 0.9% / Ratio CV 0.9%

    17.36 ms654.67 msRun117.54 ms669.35 msRun217.68 ms659.72 msRun3copy(浅い) (#b9c6d2) / deepcopy (#2f6f4f)

    Conditions

    A two-level dict copied 100,000 times.

    Where this number does not apply

    A shallow copy shares nested objects — that is exactly why it is fast, and why edits leak.

    Reproduce

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