dataclass-wizard
dataclass-wizard copied to clipboard
Optimize Dump/Serialize Process
- Dataclass Wizard version: 0.30.1 (code in this branch)
- Python version: 3.13.0
- Operating System: Mac OS
Description
I checked in updates to benchmarks in my other branch and added test cases for other libraries with the help of ChatGPT, since I'm kinda lazy and can't be bothered to do it.
Well, the results are kind of telling (below)
TLDR: Dataclass Wizard asdict is still faster than native dataclasses.asdict() -- which is expected, because I heavily adapted the code for serialization process from dataclasses module -- but it a lot slower than other libraries like e.g. pydantic.
I need to trim the fat and improve it, and I have an idea of how to do/achieve that. This issue is here to track that effort, and remind me of performance metrics (among others).
Results
benchmarks/complex.py::test_dump
--------------------------------- live log call ---------------------------------
benchmarks.complex.complex - [INFO] dataclass-wizard 1.592520
benchmarks.complex.complex - [INFO] asdict (dataclasses) 2.038759
benchmarks.complex.complex - [INFO] dataclass-factory 0.977191
benchmarks.complex.complex - [INFO] dataclasses-json 12.763810
benchmarks.complex.complex - [INFO] mashumaro 0.286038
benchmarks.complex.complex - [INFO] pydantic 0.367974
benchmarks.complex.complex - [INFO] jsons 42.078253
benchmarks.complex.complex - [INFO] jsons (strict) 41.175316