Suppose I have two Python functions, Function 1 and Function 2.

Function 1 will call Function 2 and the parameter is a big data (e.g., a dictionary with 100 thousand elements).

I am wondering if there is any performance differences between calling Function 2 in Function 1, which means I need to pass the big data parameter, and implementing Function 2 in Function 1 directly, which means I don’t need to pass the big data parameter.

Thanks.

PS: I think the key question is how Python pass the parameter, by value, or by reference (pointer)?

Edit: It seems that this is a confused problem. How do I pass a variable by reference? is a good answer.

Python passes references-to-objects by value. The terminology is controversial and ugly, but there should be no real performance difference.

Check out these answers for all the details you could ever want (hopefully).

The terminology of how python “passes” is a vicious debate I don’t want to go into. But what is actually passed on the stack is a reference. So there is not a large memory cost with either of your options.