Organising and importing files

Viewed 39

Suppose that one has a block of code in Python in a single file. Two options present themselves:

Option 1: Run the file.

Option 2: Take the first few lines and add them to a file (call it file1.py). Take the new few lines and add them to a second file (call it file2.py). Continue in this fashion until we end up with n files. Then for file i (for all i between 2 and n), write

from file i-1 import *

at the start of the file. That is, import everything from file n - 1 at the start of file n, import everything from file n - 2 at the start of file n - 1, etc. (The goal here is to 'organise' the code.) Finally, run file n.

Question: From a computational perspective, is there a difference between Option 1 and Option 2? In particular, will these ever lead to substantially different run times?

0 Answers
Related