Hi,

In an old issue, I proposed a change to not load the sysconfig module
when it's not needed. Nobody reviewed the patch, the issue was closed.

http://bugs.python.org/issue14057

When -s or -I option is used, we may skip completly the sysconfig
module. (It's already the case when -S is used.)

By the way, we should probably remove the site module. It's a pain for
the startup time :-)

Victor


2013/10/10 Christian Heimes <christ...@python.org>:
> Am 10.10.2013 02:18, schrieb Eric Snow:
>> On Wed, Oct 9, 2013 at 8:30 AM, Christian Heimes
>> <christ...@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.
>
> We don't have to use a custom module type to get rid of these imports
> (but I like to get my hands a piece of chocolate cake *g*). We can
> either implement yet another mutable mapping class for the os module.
> That would remove the dependency on collections.abc.
>
> Or we have to juggle the modules a bit so we can get to MutableMapping
> without the extra stuff from collections.__init__. The abc and
> _weakset modules are already loaded by the io module. Only
> collections.__init__ imports _collections, operator, keyword, heapq,
> itertools and reprlib.
>
> I implemented both as an experiment. A lean and mean MutableMapping
> works but it involves some code duplication. Next I moved
> collections.abc to its former place _abcoll and installed a new
> collections.abc module as facade.
>
> $ hg mv Lib/collections/abc.py Lib/_abcoll.py
> $ echo "from _abcoll import *" > Lib/collections/abc.py
> $ echo "from _abcoll import __all__" >> Lib/collections/abc.py
> $ sed -i "s/collections\.abc/_abcoll/" Lib/os.py
>
>
> With three additional patches I'm down 19 modules:
>
> $ ./python -c "import sys; print(len(sys.modules))"
> 34
> $ hg revert --all .
> $ ./python -c "import sys; print(len(sys.modules))"
> 53
>
> Christian
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to