简体   繁体   English

将大对象传递给函数是否会影响速度?

[英]Does passing a large object into a function affect speed?

Passing large json-object message : 传递大型json-object message

def foobar(message):
    ...

@bot.message_handler(content_types=['text'])
def text_handler(message):
    foobar(message)

Passing only two strings: 仅传递两个字符串:

def foobar(chat_id, text):
    ...

@bot.message_handler(content_types=['text'])
def text_handler(message):
    foobar(message.chat.id, message.text)

Python always uses a "pass-by-reference" model. Python始终使用“按引用传递”模型。 So by definition, it shouldn't affect your code performance directly. 因此,根据定义,它不应直接影响您的代码性能。 However, dealing with larger object can. 但是,处理较大的对象可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM