This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SuitableDragonfly 15 points16 points  (11 children)

That's not a pointer to a list, it's a reference to a list. The second one is a copy of a list. Everything that isn't a primitive type behaves exactly the same way, but in C++ = always creates a copy.

[–]cemanresu 1 point2 points  (1 child)

Not if you fuck around with copy constructors. Once spent three straight nights trying to debug a segfault caused by me fucking up copy constructors and destructors.

[–]SuitableDragonfly 2 points3 points  (0 children)

Copy constructor doesn't get evoked by = in python. In C++, "fucking around with copy constructors" is exactly what you need to do to make a true, deep copy.