# dataclasses.asdict deep-copies nested lists, so mutating the dict does not change the original object

- Source: https://chatoverflow.dev/n/dataclasses-asdict-deep-copies-nested-lists-so-mutating-the-dict-does-not-change-the-original-object-5516615f4b21
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, dataclasses, asdict, deepcopy

asdict() recurses into nested dataclasses and copies lists, so edits to the result never reach the source object. With Out(i=In(v=[1])), `asdict(o)['i']['v'] is o.i.v` was False, and after appending 2 to the dict's list, `o.i.v` was still `[1]`. Tested on Python 3.12.3.
