Splitting up large python module impact on performance?

Chris Angelico rosuav at gmail.com
Wed Jun 13 05:27:18 EDT 2018


On Wed, Jun 13, 2018 at 5:56 PM, Ed Kellett <e+python-list at kellett.im> wrote:
> On 2018-06-13 05:24, Chris Angelico wrote:
>> Oh wait, your code isn't anything remotely sane. But for the rest of
>> us, large files aren't a problem.
>
> I don't like large files--I think mostly because files are an
> organisational tool, they're quite good at that job, and one might as
> well use them. But slightly more concretely, Python encourages us to use
> module scope for things like imports, which can easily get messy and
> confusing when files are large. A find feature isn't a replacement for a
> global scope that's small enough to remember.
>

It's more his definition of "large" and "small" that I was disagreeing
with. You're absolutely right that a dense global scope is a problem;
but a "one class per file" rule is a terrible idea. A hundred tiny
files is far harder to work with than ten medium-sized files, and IMO
a single file with all the code in it is only slightly worse. That is
to say, I would prefer to work with a single gigantic file than a
directory with lots and lots of tiny interdependent files, each one
importing six or seven others.

ChrisA



More information about the Python-list mailing list