[Python-Dev] Python startup time (original) (raw)
Victor Stinner victor.stinner at gmail.com
Thu Oct 10 16:06:31 CEST 2013
- Previous message: [Python-Dev] Python startup time
- Next message: [Python-Dev] Python startup time
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <christian at python.org>:
Am 10.10.2013 02:18, schrieb Eric Snow:
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. 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 at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
- Previous message: [Python-Dev] Python startup time
- Next message: [Python-Dev] Python startup time
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]