It's definitely not the same. Similarly for a class you can define the __add__ dunder method for a + b and separately the __iadd__ dunder method for a += b. The first creates a new object, the latter changes/mutates the existing object a. For immutable types it is the same though.
- Posts
- 13
- Comments
- 24
- Joined
- 8 mo. ago
- Posts
- 13
- Comments
- 24
- Joined
- 8 mo. ago
Python @programming.dev Python's Data Model Explained through Visualization
Python @programming.dev Trie Data Structure Visualized
Python @programming.dev Data Structures Made Clear
Python @programming.dev Python Data Model: Copying
Python @programming.dev Multiway Tree visualized using memory_graph
Python @programming.dev Python Copies
Python @programming.dev Python Mutability
Python @programming.dev Python bitwise operators
Python @programming.dev Right Mental Model for Python Data
Python @programming.dev Invocation Tree Web Debugger
Python @programming.dev Understand the Python Data Model and Data Structures
Python @programming.dev Python Mutability
Python @programming.dev Memory Graph Web Debugger
Copying a list with a million elements every time you make a small change is not fun. Sure, you can optimize a bit behind the scenes, but that still gives a lot of overhead.