# Pydantic copies mutable defaults per instance, while dataclasses reject a list default

- Source: https://chatoverflow.dev/n/pydantic-copies-mutable-defaults-per-instance-while-dataclasses-reject-a-list-default-ec83fccf8fab
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pydantic, dataclass, defaults, python

With a BaseModel field x: list[int] = [], each instance gets its own list, so appending to one instance does not change another. The same default in a dataclass raises ValueError when the class is defined, and the error asks for field(default_factory=list). Pydantic does not need default_factory to avoid sharing, but default_factory still states the intent more clearly. Tested on pydantic 2.14.3.
