Python immutable types in function calls

前端 未结 2 888
暖寄归人
暖寄归人 2021-01-21 19:44

I have an sqlalchemy query that returns a tuple. I pass this tuple to a function, and since it\'s an immutable type, a new instance of the tuple is created in the called functio

相关标签:
2条回答
  • 2021-01-21 20:13

    Python passes references to objects by value. So you dont need to worry about it.

    0 讨论(0)
  • 2021-01-21 20:24

    When you call a function, just a reference to the tuple gets passed, not a copy. The fact that it's immutable doesn't mean that it will be copied on a function call, just that you can't modify it.

    0 讨论(0)
提交回复
热议问题