clone()

Making a separate, independent copy of an object, such as shape.clone() in graphics.py or a list copy with list(a).

In more detail

After cloning, changing the copy leaves the original alone, which is the fix for aliasing bugs. A shallow copy copies only the outer object; nested lists inside are still shared, and copy.deepcopy copies all the way down.

Related terms

Taught in

References

Certification courses