AI engineering glossary · Python core
What is shallow copy?
Shallow copy: A copy of a container that duplicates the outer object but keeps references to the same inner objects. Changing a nested mutable item through one copy therefore also changes it in the other. Made with copy.copy(), list.copy() or slicing.
Shallow copy: an example
a = [[1], [2]]; b = a.copy(); b[0].append(9) also changes a[0], which becomes [1, 9].
Related terms
More Python core terms
Where you learn it
Shallow copy is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.