2 ms·
You are correct. (I'd be surprised if other implementations passed immutable objects by value, partly because representing an "object" coherently requires sever
by zahlman 2y ago
You are correct. (I'd be surprised if other implementations passed immutable objects by value, partly because representing an "object" coherently requires several words of memory and partly because of the importance of certain object identity semantics.) Python uses pass-by-value (if you prefer, pass-by-assignment) of variables which have reference semantics. Just like non-primitive types in Java, or class types in C#.
- pansa2 2y ago> I'd be surprised if other implementations passed immutable objects by value I'm thinking of MicroPython here - it supports several pointer-tagging schemes, in which "references" might be actual pointers or might instead be immutable values stored directly. For example, using the NaN-boxing scheme, MicroPython references might actually be inline `float`s, small `int`s, or constants like `None`, `True` or `False`.