deepcopy is ~1.62× slower than JSON ラウンドトリップ
A JSON round-trip copies this structure ~1.6× faster than `deepcopy`.
Result
| Run | JSON ラウンドトリップ | deepcopy | Ratio |
|---|---|---|---|
| Run 1 | 152.371 | 245.990 | 0.62× |
| Run 2 | 153.013 | 247.056 | 0.62× |
| Run 3 | 147.808 | 243.178 | 0.61× |
Spread over 3 runs: JSON ラウンドトリップ CV 1.5% / deepcopy CV 0.7% / Ratio CV 0.9%
Conditions
A structure with a 200-item list and a 100-key dict, copied 2,000 times.
Where this number does not apply
Types that do not survive JSON (datetime, set, custom classes) make this unusable — the round-trip changes types.
Reproduce
cd bench && python micro_py.py --out ../data/run.json --samples 21