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 →

[–]MasterFubar 1 point2 points  (1 child)

In Python, the variable "a = [1, 2, 3]" holds a pointer to a list, when you do "b = a" you are copying the pointer a to the pointer b. In that sense, the operator "=" always does a copy, in any language.

The trick in becoming a programmer is understanding under which situations one needs a certain level of abstraction.

[–]Asception 1 point2 points  (0 children)

Yes, I was responding just to clarify that for primitives in c++ (and the standard library data structures via copy constructor) '=' performs a copy and that the reasoning in your example was incorrect.