Splitting up large python module impact on performance?

Chris Angelico rosuav at gmail.com
Tue Jun 12 23:35:32 EDT 2018


On Wed, Jun 13, 2018 at 1:23 PM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
> Bill Deegan wrote:
>> I'm doing some refactoring on a fairly large python
>> codebase. Some of the files are > 4000 lines long and
>> contain many classes.
>
> I would argue that files of such size are a total pain to
> navigate and thus, edit. I prefer to place only one -- or
> only a handful of classes -- in each file. One class per
> file is _most_ preferred. But if you have a small group of
> classes that are closely dependent on one another, and, the
> source definitions can fit comfortably in a single file,
> well then, i say do it. You just have to decide what is
> comfortable for _you_; your coworkers; and anyone who may be
> forced to maintain your code in the future.

A few thousand lines in a file is only a problem if you're using an
editor that lacks a Find feature. Or if you use bad function/class
names that you can't search for.

> When in doubt, and when it comes to style issues, there is
> one universal rule you should always strive to follow, and
> that rule is to be _consistent_. PEP8 underscores the
> importance of consistency, and you may want to read it.

Yep! It does. Let me see...

https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds

"""However, know when to be inconsistent -- sometimes style guide
recommendations just aren't applicable."""

> I may exaggerate on this a bit more if you're interested.

Isn't it normal for you to exaggerate everything?

ChrisA



More information about the Python-list mailing list