The parameters of Python process are passed as values

Difficult to conceive Jin 2022-05-14 13:59:05 阅读数:867


The process should open up new space Therefore, value transmission is reasonable

python The parameter transfer must be “ Pass object reference ” The way . This method is equivalent to a combination of value passing and reference passing . If the function receives
An immutable object ( Numbers 、 Characters or tuples ) References to , You can't modify the original object directly – Equivalent to passing ‘ Value passed ’ To transfer objects . If the letter
The number received is a variable object ( Dictionaries 、 list ) References to , You can change the original value of the object – amount to ‘ The reference ’ To transfer objects .

Immutable objects are hashable :int,str,Bool,tuple
Mutable objects are not hashable : Use hash Function will report an error list、dict、set

So the function object is hashable 、 Immutable The parameters of the process are also tuple types and value passing
 Insert picture description here

版权声明:本文为[Difficult to conceive Jin]所创,转载请带上原文链接,感谢。