Replies: 2 comments
-
By the way, if you provide values for model attributes, the performances are a lot better. In the previous benchmark script, if you change the foo objects creation with this FooFactory.batch(1000, id=1, name="bar") The performances are drastically better (below second) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey @g0di, thanks for reporting this! I was able to reproduce this. I'll look into this a bit more and let you know :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Folks,
After updating some of my project dependencies I noticed a signifiant increase of my tests running time (went from 30s to more than a minute). After digging I discovered that this was due to the update of pydantic from 2.4.2 to 2.8.2, after refining it looks like the the performance dropped since version 2.5.0 of pydantic.
Starting from version 2.5.0 of pydantic, the performances of
batch
function ofModelFactory
drastically dropped (~x5).How to reproduce
Considering my system spec
Using the following benchmark script
Run the following commands to setup two virtual env and run the benchmark for pydantic==2.5.0 and pydantic<2.5.0
On my side this is the output i've got
So the difference is pretty huge.
Some tracks
After digging a bit more I discovered that the the
ModelFactory.process_kwargs(...)
function was probably responsible of those numbers. It looks like this function takes way more time withpydantic>=2.5.0
. However, I did not dug more as this function was pretty complex to diagnosis for me for the moment.Perhpas Pydantic change some stuff in his public API causing this performance issue? Maybe polyfactory should use some other api of pydantic? I can't tell.
Beta Was this translation helpful? Give feedback.
All reactions