-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of MutableMapping in os module slows down interpreter startup #63417
Comments
There has been some discussion on python-dev about improving interpreter startup time. Christian Heimes brought up how the os module imports collections (so _Environ can inherit from it) [1], and mentioned a couple of solutions [2]. [1]https://mail.python.org/pipermail/python-dev/2013-October/129312.html |
Here is a patch for an alternate approach. It does not require re-implementing MutableMapping (could get out of sync) and does not require rearranging collections.abc. Instead it uses a metaclass to resolve the import issue lazily. |
Nice trick :) |
And when the lazy base class gets resolved, the metaclass gets to say "You didn't see anything and I was never here." :) |
-1 on such hacks. I much prefer the _abcoll approach. |
The collections module is loaded by the io module. You removed "from collections.abc import MutableMapping" from os.py. To be useful, you have also to rewrite the whole io module to remove all references to the collections.abc module, right? |
The io module no longer imports collections.abc through the locale module. Eric, I'm with Antoine. Your patch is too much of a clever hack and uses tricks that are dark magic. _abcoll is much simpler and easier to understand. Plus it can be used from other modules, too. |
Not a problem. It is most definitely a hack. :) I put in up as an alternative to rearranging the collections module, but agree that doing so is preferable. I image that Raymond will make a decision on that one. |
Christian, go ahead an rearrange the collections module. Move Lib/collections/abc.py to Lib/_collections_abc.py. Also, be sure to update source link on line 18 of Doc/library.collections.abc.rst |
New changeset 0b6052f2a8ee by Christian Heimes in branch 'default': New changeset 7ea831581af4 by Christian Heimes in branch 'default': New changeset 62b6ecd1e463 by Christian Heimes in branch 'default': |
Thank you very much for your input and assistance! tip compared to v3.4.0a3: ### normal_startup ### |
Thanks, Christian. |
For backward compatibility, shouldn't import _collections_abc in the __init__ file be import _collections_abc as abc ? |
Opened bpo-20784 to address the above. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: