MCPcopy Index your code
hub / github.com/RustPython/RustPython / init_importlib_base

Function init_importlib_base

crates/vm/src/import.rs:15–35  ·  view source on GitHub ↗
(vm: &mut VirtualMachine)

Source from the content-addressed store, hash-verified

13}
14
15pub(crate) fn init_importlib_base(vm: &mut VirtualMachine) -> PyResult<PyObjectRef> {
16 flame_guard!("init importlib");
17
18 // importlib_bootstrap needs these and it inlines checks to sys.modules before calling into
19 // import machinery, so this should bring some speedup
20 #[cfg(all(feature = "threading", not(target_os = "wasi")))]
21 import_builtin(vm, "_thread")?;
22 import_builtin(vm, "_warnings")?;
23 import_builtin(vm, "_weakref")?;
24
25 let importlib = thread::enter_vm(vm, || {
26 let bootstrap = import_frozen(vm, "_frozen_importlib")?;
27 let install = bootstrap.get_attr("_install", vm)?;
28 let imp = import_builtin(vm, "_imp")?;
29 install.call((vm.sys_module.clone(), imp), vm)?;
30 Ok(bootstrap)
31 })?;
32 vm.import_func = importlib.get_attr(identifier!(vm, __import__), vm)?;
33 vm.importlib = importlib.clone();
34 Ok(importlib)
35}
36
37#[cfg(feature = "host_env")]
38pub(crate) fn init_importlib_package(vm: &VirtualMachine, importlib: PyObjectRef) -> PyResult<()> {

Callers 1

initializeMethod · 0.85

Calls 6

import_builtinFunction · 0.85
enter_vmFunction · 0.85
import_frozenFunction · 0.85
get_attrMethod · 0.45
callMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected