Earlier quoted context omitted.
Is python no longer a modern language? Objects are certainly not copied when passed to a function.
Python copies references by value. $ python3 Python 3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def x(): ... v = 1 ... y(v) ... print(v) ... >>> def y(val): ... val += 1 ... >>> x() 1 A pass-by-reference language would print 2. Everything in a modern language is passed by copy. Exactly what is copied varies and can easily be poi…
Python passes primitive types by value, out rather "as if by value", because it copies them on write.
if you modify your experiment to pass around a dict or list and modify that in the 'y', you'll see y is happily modified.
so Python passes by reference, however it either blocks updates (tuple) or copies on write (int, str, float) or updates in place (dict, list, class)