RepoJournal
FastAPI & Pydantic

FastAPI & Pydantic

FastAPI and the Pydantic + SQLModel async-Python stack

Pick a date

The Wire · Showcase

PYDANTIC FIXES DEEPCOPY CRASH IN MODEL_COPY

By RepoJournal · Filed · About FastAPI & Pydantic

Pydantic's `model_copy(deep=True)` no longer tries to deepcopy fields you're about to replace, fixing crashes when those fields hold undeepcopyable objects like GPU tensors or C extensions.

The fix [1] is surgical and high-impact. Before, `model_copy(deep=True, update={...})` would deepcopy every field including ones you're immediately replacing, which breaks when those fields contain native C extensions, file handles, or GPU tensors. Now it only deepcopies fields that survive the update, and it properly maintains shared references between fields by using a single `memo` dict across all deepcopy calls. This preserves the behavior for `__pydantic_extra__` and `__pydantic_private__` as well. In parallel, the Pydantic team fixed a mypy plugin regression [2] where `create_model(..., __base__=cls)` inside a classmethod would lose the `Self` type. The mypy plugin now falls back to the normal overload definition when `__base__` is a type variable, keeping proper generic inference. Expect these in the next release.

Action items

References

  1. [1] Only deepcopy non-updated fields in `model_copy()` ↗ pydantic/pydantic
  2. [2] Fallback to `create_model()` overload definition when `__base__` is set to a type variable ↗ pydantic/pydantic

FAQ

What changed in FastAPI & Pydantic on May 17, 2026?
Pydantic's `model_copy(deep=True)` no longer tries to deepcopy fields you're about to replace, fixing crashes when those fields hold undeepcopyable objects like GPU tensors or C extensions.
What should FastAPI & Pydantic teams do about it?
Watch for next Pydantic release with model_copy fix if you use deep=True with GPU tensors or C extension fields • If using dynamic models with create_model in classmethods, test with upcoming Pydantic release for proper type narrowing
Which FastAPI & Pydantic repositories shipped on May 17, 2026?
pydantic/pydantic

Related across the cluster

For your repos

The showcase is a teaser.
Your wire is the product.

Same engine. Different stack. Below: what changes when the wire is yours.

Showcase wire

  • 14 famous open source orgs
  • One wire per day
  • Public, generic
  • Read on the web, when you remember

Your wire

  • Up to 1,500 of your repos - orgs, deps, vendors
  • Morning and evening briefs
  • Action items routed to your team
  • Slack delivery, email, breaking-news CVE alerts

Want a hands-on demo first? Ask a current user for an invite link.