Issue33440
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.
Created on 2018-05-07 12:28 by ncoghlan, last changed 2022-04-11 14:59 by admin.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 6820 | open | agf, 2018-05-14 19:17 | |
| Messages (4) | |||
|---|---|---|---|
| msg316266 - (view) | Author: Alyssa Coghlan (ncoghlan) * ![]() |
Date: 2018-05-07 12:28 | |
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) |
|||
| msg316276 - (view) | Author: Nathaniel Smith (njs) * ![]() |
Date: 2018-05-07 17:21 | |
Also it's a smaller win, but it might be worth considering whether we can avoid the import of 'nt' on posix platforms and vice-versa. |
|||
| msg316567 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-05-14 19:51 | |
Did you mean the idea about module-level alias to dirname(__file__)? I think this is a dead horse. See issue33277. |
|||
| msg316570 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-05-14 20:03 | |
Personally I support moving imports of rarely used modules into functions that need them. But this is against PEP 8 and should be discussed more widely. Perhaps this rule should be weaken, we have to state what exceptions are permitted. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:00 | admin | set | github: 77621 |
| 2018-05-14 20:03:34 | serhiy.storchaka | set | messages: + msg316570 |
| 2018-05-14 19:51:15 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg316567 |
| 2018-05-14 19:17:51 | agf | set | keywords:
+ patch stage: patch review pull_requests: + pull_request6505 |
| 2018-05-07 17:21:49 | njs | set | messages: + msg316276 |
| 2018-05-07 12:28:40 | ncoghlan | create | |
