Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare to pydantic v2 #524

Merged
merged 2 commits into from
Dec 13, 2023
Merged

Compare to pydantic v2 #524

merged 2 commits into from
Dec 13, 2023

Conversation

Olegt0rr
Copy link
Contributor

@Olegt0rr Olegt0rr commented Aug 17, 2023

Relates to #523

Also need to

  • Update results

Also would be great to add both pydantic version comparison.

My results:

Benchmark - 1000 objects with validation

msgspec
  dumps: 126.68 us
  loads: 324.15 us
  total: 450.83 us

pydantic
  dumps: 2478.84 us
  loads: 1886.44 us
  total: 4365.29 us

cattrs
  dumps: 2025.52 us
  loads: 2365.95 us
  total: 4391.47 us

mashumaro
  dumps: 785.82 us
  loads: 1392.68 us
  total: 2178.51 us

pip freeze

annotated-types==0.5.0
attrs==23.1.0
cattrs==23.1.2
certifi==2023.7.22
charset-normalizer==3.2.0
idna==3.4
mashumaro==3.9
msgpack==1.0.5
-e git+https://github.com/Olegt0rr/msgspec.git@0041a67b77ee91286b5e76b6529ee3e32f66df6b#egg=msgspec
orjson==3.9.5
pydantic==2.1.1
pydantic_core==2.4.0
requests==2.31.0
typing_extensions==4.7.1
ujson==5.8.0
urllib3==2.0.4

@akotlar
Copy link

akotlar commented Oct 8, 2023

Impressive advantage for msgspec vs pydantic v2

@ofek
Copy link

ofek commented Nov 22, 2023

cc @samuelcolvin

- Update benchmarks generally
- Benchmark against Pydantic V2 instead of V1
- Adds a few additional JSON and MessagePack libraries
- Documents the versions of libraries used for each run
- Bumps the python version used from 3.9 to 3.11. This made several of
  the pure-python libraries compared measurably faster. Yay for the
  faster CPython initiative.
@jcrist jcrist merged commit f71d96f into jcrist:main Dec 13, 2023
8 checks passed
@jcrist
Copy link
Owner

jcrist commented Dec 13, 2023

Thanks for the PR and apologies for the delay here, I haven't had as much time as usual to devote to OSS activities lately. I've pushed an extra commit to this PR that does a major overhaul to the benchmarks. A brief summary:

  • Benchmark against Pydantic V2 instead of V1
  • Adds a few additional JSON and MessagePack libraries
  • Documents the versions of libraries used for each run
  • Bumps the python version used from 3.9 to 3.11. This made several of the pure-python libraries compared measurably faster. Yay for the faster CPython initiative.

@jcrist jcrist mentioned this pull request Dec 13, 2023
@Olegt0rr Olegt0rr deleted the update-benchmarks branch December 13, 2023 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants