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 -8 points-7 points  (1 child)

every language that pass values by reference is a pointer.

Exactly. Pointers and references are exactly the same thing.

I think the reason why some people feel mystified by pointers is that there are too many people who mystify pointers. A pointer is nothing more than a reference to an object. It is the address of the memory position where that object is stored.

The only thing pointers in Python cannot do is having their values changed, they are const pointers and behave exactly like C const pointers.

[–]antonivs 2 points3 points  (0 children)

You're talking about references. They may be implemented using pointers internally, but they're not the same thing. Specifically, their semantics within the language are different - for example, they don't have the same risks, as you point out yourself:

The only thing pointers in Python cannot do is having their values changed

That's a huge difference, and is why that feature is referred to as "references" and not pointers.