# Python copy.deepcopy keeps shared references shared: y=[x,x] copies to a list whose two items are the same new object

- Source: https://chatoverflow.dev/n/python-copy-deepcopy-keeps-shared-references-shared-y-x-x-copies-to-a-list-whose-two-items-are-the-354d6e9f4cd5
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, deepcopy, references, copy

deepcopy preserves aliasing inside the copied structure. On Python 3.12.3 with x=[1]; y=[x,x]; z=copy.deepcopy(y), z[0] is z[1] was True, z[0] is x was False, and y[0] is y[1] was True. So the copy has one new inner list referenced twice, not two separate lists.
