home.social

#deepcopy — Public Fediverse posts

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

fetched live
  1. An exercise to help build the right mental model for Python data.
    - Solution: memory-graph.com/#codeurl=http
    - Explanation: github.com/bterwijn/memory_gra

    The “Solution” link visualizes execution and reveals what’s actually happening using 𝗺𝗲𝗺𝗼𝗿𝘆_𝗴𝗿𝗮𝗽𝗵: lnkd.in/e3sUM7wG

  2. An exercise to help build the right mental model for Python data. The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening:
    - Solution: memory-graph.com/#codeurl=http
    - Explanation: github.com/bterwijn/memory_gra

    If you think this could help Python students and educators, please boost.

  3. Python copies:
    - c1: assignment, nothing is copied, all the values are shared
    - c2: shallow copy, only the first value is copied, all the underlying values are shared
    - c3: custom copy, you decide what is copied and shared
    - c4: deep copy, everything is copied, nothing is shared

    🧠 Learn the right mental model to think about Python data: github.com/bterwijn/memory_gra

    🎥 See the Quick Intro video for the VS Code setup: youtu.be/23_bHcr7hqo

  4. Deep Copy vs Reference Copy of Arrays in C# Tip #46 - Understanding array copying: reference types share the same memory (like a shared toy box), while deep copies create separate data. Use Clone(), Array.Copy(), or ToArray() for deep copies.
    #ArrayCopy #DeepCopy #ReferenceTypes #CSharp #ProgrammingBasic #LearnCoding

  5. Deep Copy vs Reference Copy of Arrays in C# Tip #46 - Understanding array copying: reference types share the same memory (like a shared toy box), while deep copies create separate data. Use Clone(), Array.Copy(), or ToArray() for deep copies.
    #ArrayCopy #DeepCopy #ReferenceTypes #CSharp #ProgrammingBasic #LearnCoding

  6. @matt

    This does bite people in Python, as it applies to lists and dicts in addition to Pandas or whatever that is.

    list and dict have copy() methods, but they're shallow copies. If you have mutable objects in your list or dict, those can be changed by someone with a copy...

    Use copy.deepcopy() to ensure you get a mutable object that no one else (barring evil intent...) has a handle to fiddle with its contents.

    #python #mutable #DeepCopy

  7. @matt

    This does bite people in Python, as it applies to lists and dicts in addition to Pandas or whatever that is.

    list and dict have copy() methods, but they're shallow copies. If you have mutable objects in your list or dict, those can be changed by someone with a copy...

    Use copy.deepcopy() to ensure you get a mutable object that no one else (barring evil intent...) has a handle to fiddle with its contents.

    #python #mutable #DeepCopy