Does importing more slow down scripts python?

前端 未结 1 1237
情书的邮戳
情书的邮戳 2021-01-12 12:53

Just wondering if importing more functions from other scripts slows down a script in general?

Some background:

I have two scripts, one that runs much faster

相关标签:
1条回答
  • 2021-01-12 13:29

    More information about your case, Import_Statement_Overhead:

    Import statements can be executed just about anywhere. It's often useful to place them inside functions to restrict their visibility and/or reduce initial startup time. Although Python's interpreter is optimized to not import the same module multiple times, repeatedly executing an import statement can seriously affect performance in some circumstances.

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