Pyベンチ実測MEASURED, NOT RECALLED

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

    json.dumps is ~2.62× slower than pickle.dumps

    Serialising the same small dict 20,000 times: pickle is ~2.6× faster than json.

    Result

    Runjson.dumpspickle.dumpsRatio
    Run 156.74222.7912.49×
    Run 256.49521.6612.61×
    Run 358.30021.6372.69×

    Spread over 3 runs: json.dumps CV 1.4% / pickle.dumps CV 2.5% / Ratio CV 3.2%

    56.74 ms22.79 msRun156.49 ms21.66 msRun258.30 ms21.64 msRun3json.dumps (#b9c6d2) / pickle.dumps (#2f6f4f)

    Conditions

    A 4-key dict dumped 20,000 times; pickle protocol 5.

    Where this number does not apply

    pickle wins on speed only; json wins on portability, and unpickling untrusted data is unsafe.

    Reproduce

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