MarkusSintonen

Results 29 comments of MarkusSintonen

Hi! We are also seeing this issue. We are initializing FastAPI with a default response for unexpected error responses for OpenAPI spec: ``` FastAPI(..., responses={"default": {"model": UnexpectedErrorResponse}}) ``` After updating...

We are also heavily hit by this issue. But we added a hacky workaround for our tests which speeds up the test initialization hugely! It would be great to get...

> Can you watch this? Perhaps it could be better, I just started to deal with this framework. Below seems to also work when using Pydantic dataclass. But you need...

> Any progress on a reproducible example? Sorry, no 😞 I tried to repro it locally, but was unable to do it in reasonable time. Also have been too busy...

Wow amazing investigation @samuelcolvin! Thank you 🙏 > do you use generics with pydantic, and GenericModel in particular? Yes we use `GenericModel`s for example with some FastAPI request/response models. >...

> One more question, I assume you're also generating schema from your models? That's where I found the use of `issubclass` that is causing problems in cpython. Yes we are...

> Do you create models dynamically? E.g. call create_model or create new dataclasses or parse_obj_as or similar regularly at runtime? Can the issue be triggered by using `GenericModel` like this?:...

Hi! We upgraded to Pydantic 1.10.2 from 1.8.2. We didnt observe any memory anomaly anymore like we did with 1.9.0. So I think the main issue has been solved. Thank...

@Kludex, @marianhlavac adding support is easy so I did it here: https://github.com/tiangolo/fastapi/pull/11306

When I try to patch FastAPI so it memoizes the `FieldInfo`->`TypeAdapter` mapping, it reduces the initialization time from ~20s to ~10s. So it seems its doing some unnecessary work there....