home.social

#pythongotcha — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #pythongotcha, aggregated by home.social.

  1. #PythonGotcha 🧵

    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: realpython.com/python-mutable-

    #learning #objects #python #dev #CS #DataScience #memory #dataDev