This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients ncoghlan, njs, pitrou
Date 2018-05-07.12:28:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1525696120.71.0.682650639539.issue33440@psf.upfronthosting.co.za>
In-reply-to
Content
Due to a python-ideas discussion about reducing boilerplate for __file__-relative path calculations, I was running "./python -X importtime -S -c 'import pathlib'" and noticed three potential candidates where it may be worthwhile deferring the imports until the modules are actually needed:

- re (used in _WildcardSelector)
- fnmatch (used in PurePath.match and _WildcardSelector)
- urllib.parse (used in PurePath.as_uri, by way of self._flavour.make_uri)

Using an optimised Python 3.7 on an SSD with warm disk caches, commenting out those 3 imports reduced my typical import times for pathlib from 12-13 ms to 7-8 ms)
History
Date User Action Args
2018-05-07 12:28:40ncoghlansetrecipients: + ncoghlan, pitrou, njs
2018-05-07 12:28:40ncoghlansetmessageid: <1525696120.71.0.682650639539.issue33440@psf.upfronthosting.co.za>
2018-05-07 12:28:40ncoghlanlinkissue33440 messages
2018-05-07 12:28:40ncoghlancreate