diff options
author | Paul m. p. P <pmpp.pub@gmail.com> | 2019-07-19 00:54:12 +0200 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-07-31 22:36:00 +1000 |
commit | 60f1063797716cfec14c84afafec69bf06127777 (patch) | |
tree | 519d822cb042395d881d60d90a267e03fe4055a1 /tests/basics/builtin_override.py | |
parent | a8e3201b376d931a77e66dc80293c570983f9c7b (diff) |
py/runtime: Allow to override builtins.__import__ with Python func.
This patch adds a simple but powerful hook into the import system, in a
CPython compatible way, by allowing to override builtins.__import__.
This does introduce some overhead to all imports but it's minor:
- the dict lookup of __import__ is bypassed if there are no modifications
to the builtins module (which is the case at start up);
- imports are not performance critical, usually done just at the start of a
script;
- compared to how much work is done in an import, looking up a value in a
dict is a relatively small additional piece of work.
Diffstat (limited to 'tests/basics/builtin_override.py')
0 files changed, 0 insertions, 0 deletions