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.

classification
Title: Optimize repeated calls to `__import__()`
Type: performance Stage: resolved
Components: Interpreter Core, Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Kronuz, miss-islington
Priority: normal Keywords: patch

Created on 2021-03-03 20:48 by Kronuz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24735 merged Kronuz, 2021-03-03 21:02
Messages (2)
msg388057 - (view) Author: Germán Méndez Bravo (Kronuz) * Date: 2021-03-03 20:48
A call to `importlib.__import__()` normally locks the import for the module being worked on; this, however has a performance impact for modules that are already imported and fully initialized. An example of this are inline `__import__()` calls in a hot path that is called repeatedly during the life of the process.

Proposal: A two steps check in `importlib._bootstrap._find_and_load()` to avoid locking when the module has been already imported and it's ready.
msg399477 - (view) Author: miss-islington (miss-islington) Date: 2021-08-12 18:23
New changeset 03648a2a91f9f1091cd21bd4cd6ca092ddb25640 by Germán Méndez Bravo in branch 'main':
bpo-43392: Optimize repeated calls to `__import__()` (GH-24735)
https://github.com/python/cpython/commit/03648a2a91f9f1091cd21bd4cd6ca092ddb25640
History
Date User Action Args
2022-04-11 14:59:42adminsetgithub: 87558
2021-08-12 18:24:32pitrousetstatus: open -> closed
versions: + Python 3.11, - Python 3.6, Python 3.7, Python 3.8, Python 3.9, Python 3.10
resolution: fixed
components: + Interpreter Core
type: performance
stage: patch review -> resolved
2021-08-12 18:23:43miss-islingtonsetnosy: + miss-islington
messages: + msg399477
2021-03-03 21:02:29Kronuzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request23506
2021-03-03 20:48:50Kronuzcreate