How to import all things defined the files in a module directory in __init__.py?

Steve D'Aprano steve+python at pearwood.info
Sat Sep 24 06:47:57 EDT 2016


On Sat, 24 Sep 2016 04:59 pm, Lawrence D’Oliveiro wrote:

> On Saturday, September 24, 2016 at 2:11:09 PM UTC+12, Chris Angelico
> wrote:
>> It's a large and complex module, and about at the boundary of being
>> broken up a bit.
> 
> Splitting it up would make it slower to load.

Would it? You've bench marked it and found that it makes a significant
difference?

In any case, you're missing the point. Size carries its own cost to the
human reader, never mind whether or not the interpreter can deal with it:

https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two

The decimal module is approaching a size where it is no longer comfortable
to read or edit:

- 6450 lines in the source file (include comments, blanks, etc);

- 27 top-level functions;

- 54 global variables/constants;

- 19 classes, which isn't too bad on its own, but:

- one of those classes has 83 methods;

- and another has 127 methods;

- the Decimal class itself is 3311 lines alone; excluding blanks, comments
and docstrings, it is 2013 SLOC.

This a partly a matter of taste, and to my taste, the decimal module is
about as big as I would like to see a module before I split it into
submodules purely on the basis of size.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list