python 中导入模块的数量是否会影响内存和性能?
Does the number of imported modules in python effect memory and performance?
在 python 中导入模块时,从包中导入单个模块时是否存在内存差异,例如:from math import ceil 与整个包,例如: 导入数学?我想我真正想问的是当脚本为 运行?
时它是否会减慢处理速度
它们之间没有区别。 Raymond Hettinger,核心 Python 开发人员之一,最近发推文:
#python tip: from-imports don't save memory. They execute and cache the entire module just like a regular import.
在 python 中导入模块时,从包中导入单个模块时是否存在内存差异,例如:from math import ceil 与整个包,例如: 导入数学?我想我真正想问的是当脚本为 运行?
时它是否会减慢处理速度它们之间没有区别。 Raymond Hettinger,核心 Python 开发人员之一,最近发推文:
#python tip: from-imports don't save memory. They execute and cache the entire module just like a regular import.