Performance when passing huge list as argument in recursive function?

后端 未结 2 677
轮回少年
轮回少年 2021-01-14 15:41

I am using Python and I have a recursive function that takes a huge list as one of the arguments:

# Current implementation
def MyFunction(arg1, arg2, my_huge         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 16:18

    No, arguments in Python are passed by reference.
    More precisely - variables in Python is just a pointers that stores memory-addresses of actual data. So when Pythons variable-pointer passed to a function - it passed by its value - address pointing to actual data, it means that, variables passed to functions by value and value of variables are references to objects.

    More on that topic:

    • http://testingreflections.com/node/5126
    • http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables

提交回复
热议问题