python - 将大对象传递给函数会影响速度吗?
问题描述
传递大型 json-object message
:
def foobar(message):
...
@bot.message_handler(content_types=['text'])
def text_handler(message):
foobar(message)
只传递两个字符串:
def foobar(chat_id, text):
...
@bot.message_handler(content_types=['text'])
def text_handler(message):
foobar(message.chat.id, message.text)
解决方案
Python 始终使用“按引用传递”模型。所以根据定义,它不应该直接影响你的代码性能。但是,处理较大的对象可以。
推荐阅读
- metrics - 用于监视的 Azure CDN 指标
- docker - 通过 AWS-Greengrass 连接器服务部署 Docker 映像时面临的问题
- bash - 在 bash 脚本中获取传递参数的错误值到函数
- javascript - 如何使用javascript将每个句子的第一个字符大写一个段落?
- mongodb - 在pentaho PDI的单个字段中选择mongodb aray元素
- twilio - Twilio Video API 向所有参与者发出自定义事件 (javascript)
- discord.py - Discord.py eval 命令:IndentationError:期望缩进块
- java - 在 mapStore 中动态创建地图
- node.js - 使用mongoose查询MongoDB内部数组的状态
- html - Angular 反应式表单控件默认值没有影响