Which is the best: create the modules and put them in a separate file and import them or put them all together in the same file?
Is there any significant difference?
Same as disscussion on .py and .pyc. Having modules allows you to load them faster through precompiled modules. How ever negligible, this adds to performance. Though execution speed remains the same.
Please look at the following for a detailed answer. Repeating it is not useful.
- What is the difference between .py and .pyc files?
- Why are main runnable Python scripts not compiled to pyc files like modules?
Decomposing the solution in modules is always better for future maintenance and enhances readability. The performance is almost always not the primary reason for decomposition of solution into various modules.