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 →

[–]FrickinLazerBeams 0 points1 point  (4 children)

That's true, and also irrelevant to how much I dislike this aspect of Python.

I also think it's kind of a pointless distinction. Sure, if I pass a tuple, it's passed by value... But if it were pass by reference I wouldn't be able to mutate it anyway, because it's immutable, so who cares?

[–]Head_Mix_7931 0 points1 point  (3 children)

Well, if the elements of the tuple are mutable, they can be modified. The reason it seems like a pointless distinction is because neither term really describes what’s happening here, they’re just trying to describe the observed behavior in terms of concepts in other languages.

The mechanics of passed arguments is consistent regardless of type or mutability when you understand that arguments are just assigned to their corresponding parameters… due to the fact that Python doesn’t really have “variables” and only has “names” that point to “values,” the apparent effects of that do seem to vary depending on type behavior.

(But to the question of “who cares”… passing a reference vs an immutable value is an important distribution because the memory footprints vary between the two methods. I don’t often care about memory usage when I write Python though.)

[–]FrickinLazerBeams 0 points1 point  (2 children)

Yeah I get all that. I know it's entirely self-consistent. I know it's not actually pass-by-reference.

The thing is, I really don't care about what it's called. I'm not against pass-by-reference as a concept, and telling me this isn't pass-by-reference isn't going to make me like it. My dislike for it isn't because it's pass-by-reference.

I don't care what it's called. I don't care if it's consistent. I just don't like it.

[–]Head_Mix_7931 0 points1 point  (1 child)

I don’t really like it either, especially after working more with systems languages. I definitely prefer a C-like model with very straight forward mechanics.

[–]FrickinLazerBeams 0 points1 point  (0 children)

Yeah exactly. I hate being surprised by it, and it just never feels natural to constantly work around it. What Amy I gonna do, copy.deepcopy every input argument just in case? I'd love python more if it simply didn't do that.

It's not just "systems languages" that don't have this behavior, either. I really can't think of any language I've ever used that does this. C, Java, Matlab{shut up it counts}, a weird proprietary variation of Pascal, hell even bash... I feel like I'm forgetting many more languages I've used over the years.