In a Django web application, would large files or many unnecessary import statements slow down my server?
Question: In my Django web app, I have pretty much one large file that contains all my
views. This has a ton of imported python libraries that are only used for
certain views.

Does this slow my code? Like in python does importing things like python
natural language toolkit (nlkt) and threading libraries slow down the code
when its not needed?

I know its not great for a maintainability/style standpoint to have one big
file like this, but I am asking purely from a performance standpoint.


Answer: No, code speed is not affected by the size of your modules.

Additional imports only affect the memory footprint (a little more memory is
needed to hold the extra code objects) and startup speed (more files are
loaded from disk when your Django server starts).

However, this doesn't really affect code running speeds; Python does not have
to do extra work to run your code.

