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: beanie-odm.dev
Beanie on GitHub: github.com
Roman on Twitter: @roman_the_right
Beanie Release 1.21.0: github.com
Talk Python's MongoDB with Async Python Course: talkpython.fm
Pydantic Migration Guide: docs.pydantic.dev

Customizing validation with __get_pydantic_core_schema__: docs.pydantic.dev
Bunnet (Sync Beanie): github.com
Generic `typing.ForwardRef` to support generic recursive types: discuss.python.org
Pydantic v2 - The Plan Episode: talkpython.fm
Future of Pydantic and FastAPI episode: talkpython.fm
Beanie Lazy Parsing: beanie-odm.dev
Beanie Relationships: beanie-odm.dev
Locust Load Testing: locust.io
motor package: pypi.org
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to us on YouTube: youtube.com
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