[Python-Dev] Python startup time

Eric Snow ericsnowcurrently at gmail.com
Thu Oct 10 02:18:20 CEST 2013


On Wed, Oct 9, 2013 at 8:30 AM, Christian Heimes <christian at python.org> wrote:
> The os module imports MutableMapping from collections.abc. That import
> adds collections, collections.abc and eight more modules. I'm not sure
> if we can do anything about it, though.

Well, that depends on how much we want to eliminate those 10 imports.
:)  Both environ and environb could be turned into lazy wrappers
around an _Environ-created-when-needed.  If we used a custom module
type for os [1], then adding descriptors for the two attributes is a
piece of cake.  As it is, with a little metaclass magic (or even with
explicit wrapping of the various dunder methods), we could drop those
10 imports from startup.

-eric

[1] This probably wouldn't be a great idea considering that
undoubtedly some code depends on "type(os) is types.ModuleType".


More information about the Python-Dev mailing list