r/learnmachinelearning • • Oct 17 '26

Question Python Mutability and Copying

Post image
0 Upvotes

12 comments sorted by

View all comments

-1

u/FastSlow7201 Oct 17 '26

a and b are both pointers to the same memory location.

copy.deepcopy() will copy a and create b in a separate memory location.

1

u/Sea-Ad7805 Oct 17 '26

Yes, see the shallow vs deep copy Explanation here: https://github.com/bterwijn/memory_graph#copying-values-of-mutable-type

But what is your answer?

1

u/FastSlow7201 Oct 17 '26

d, but my answer was essentially in my original comment

1

u/Sea-Ad7805 Oct 17 '26

Incorrect sorry, see Solution link (in original post, click title) for correct answer.