#pythongotcha — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #pythongotcha, aggregated by home.social.
-
It is often useful to make a #copy of a given list before performing operations that would mutate the elements.
When you make a shallow copy of an existing list, you create a new pointer to a new list object that points to the same old elements. (It saves memory.)
On the other hand, if you make a deep copy, then you create a completely new copy of the original list.
In other words: https://realpython.com/python-mutable-vs-immutable-types/#making-copies-of-lists
#learning #objects #python #dev #CS #DataScience #memory #dataDev