Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on programming.dev
python·Pythonbybterwijn

Python Data Model: Copying

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:

View original on programming.dev
14

8 replies

bterwijnreply
programming.dev

Incorrect sorry, check the "Solution" link for the correct answer.

2

Oh du-duoy. Forgot that list of list is a list of pointers somehow while also remembering a list is a pointer. Thanks.

1
lemmy.ml

Preferred solution: learnyouahaskell.com . For immutable data!

-3

Different languages make different choices. The disadvantage of Haskell is that if you want to change one value in a collection of a million values that it either makes a full copy or tries to optimize by sharing values behind the scene, both resulting in significant overhead. Most people already understand that pure functional programming languages don't deliver except in very specific circumstances: Haskell TIOBE rating 0.32%, https://www.tiobe.com/tiobe-index/

1

You reached the end

Python Data Model: Copying | Spyke