9

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 than the other, one has an extra import statement at the top and extra function at the bottom, but its the stuff in the middle, thats the same between scripts that is running slower.

user124123
  • 1,642
  • 7
  • 30
  • 50

1 Answers1

13

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.

Hooked
  • 84,485
  • 43
  • 192
  • 261
badc0re
  • 3,333
  • 6
  • 30
  • 46