Monitor performance issues & errors in your code

Migrating to Pydantic 2.0: Beanie for MongoDB

Episode #432, published Fri, Oct 6, 2023, recorded Wed, Aug 16, 2023

By now, surely you've heard how awesome Pydantic version 2 is. The team led by Samual Colvin spent almost a year refactoring and reworking the core into a high-performance Rust version while keeping the public API in Python and largely unchanged. The main benefit of this has been massive speed ups for frameworks and devs using Pydantic.

But just how much work is it to take a framework deeply built on Pydantic and make that migration? What are some of the pitfalls? On this episode, we welcome back Roman Right to talk about his experience converting Beanie, the popular MongoDB async framework based on Pydantic, from Pydantic v1 to v2. And we'll have some fun talking MongoDB as well while we are at it.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Links from the show

Beanie on GitHub:
Roman on Twitter: @roman_the_right
Beanie Release 1.21.0:
Talk Python's MongoDB with Async Python Course:
Pydantic Migration Guide:

Customizing validation with __get_pydantic_core_schema__:
Bunnet (Sync Beanie):
Generic `typing.ForwardRef` to support generic recursive types:
Pydantic v2 - The Plan Episode:
Future of Pydantic and FastAPI episode:
Beanie Lazy Parsing:
Beanie Relationships:
Locust Load Testing:
motor package:
Watch this episode on YouTube:
Episode transcripts:

--- Stay in touch with us ---
Subscribe to us on YouTube:
Follow Talk Python on Mastodon: talkpython
Follow Michael on Mastodon: mkennedy

Want to go deeper? Check out our courses

Talk Python's Mastodon Michael Kennedy's Mastodon