diff options
author | Germán Méndez Bravo <kronuz@fb.com> | 2021-08-12 18:23:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 18:23:29 (GMT) |
commit | 03648a2a91f9f1091cd21bd4cd6ca092ddb25640 (patch) | |
tree | 0f7f969f440abdce580317be0ba70aaf5216bcdc /Python/getplatform.c | |
parent | 953d27261e455066b17a106d9e07bab3bf12983b (diff) | |
download | cpython-03648a2a91f9f1091cd21bd4cd6ca092ddb25640.zip cpython-03648a2a91f9f1091cd21bd4cd6ca092ddb25640.tar.gz cpython-03648a2a91f9f1091cd21bd4cd6ca092ddb25640.tar.bz2 |
bpo-43392: Optimize repeated calls to `__import__()` (GH-24735)
Implements a two steps check in `importlib._bootstrap._find_and_load()` to avoid locking when the module has been already imported and it's ready.
---
Using `importlib.__import__()`, after this, does show a big difference:
Before:
```
$ ./python -c 'import timeit; print(timeit.timeit("__import__(\"timeit\")", setup="from importlib import __import__"))'
15.92248619502061
```
After:
```
$ ./python -c 'import timeit; print(timeit.timeit("__import__(\"timeit\")", setup="from importlib import __import__"))'
1.206068897008663
```
---
Diffstat (limited to 'Python/getplatform.c')
0 files changed, 0 insertions, 0 deletions