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

Function core_frozen_inits

crates/vm/src/vm/interpreter.rs:460–553  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

458}
459
460fn core_frozen_inits() -> impl Iterator<Item = (&'static str, FrozenModule)> {
461 let iter = core::iter::empty();
462 macro_rules! ext_modules {
463 ($iter:ident, $($t:tt)*) => {
464 let $iter = $iter.chain(py_freeze!($($t)*));
465 };
466 }
467
468 // Python modules that the vm calls into, but are not actually part of the stdlib. They could
469 // in theory be implemented in Rust, but are easiest to do in Python for one reason or another.
470 // Includes _importlib_bootstrap and _importlib_bootstrap_external
471 ext_modules!(
472 iter,
473 dir = "../../Lib/python_builtins",
474 crate_name = "rustpython_compiler_core"
475 );
476
477 // core stdlib Python modules that the vm calls into, but are still used in Python
478 // application code, e.g. copyreg
479 // FIXME: Initializing core_modules here results duplicated frozen module generation for core_modules.
480 // We need a way to initialize this modules for both `Interpreter::without_stdlib()` and `InterpreterBuilder::new().init_stdlib().interpreter()`
481 // #[cfg(not(feature = "freeze-stdlib"))]
482 ext_modules!(
483 iter,
484 dir = "../../Lib/core_modules",
485 crate_name = "rustpython_compiler_core"
486 );
487
488 // Collect frozen module entries
489 let mut entries: Vec<_> = iter.collect();
490
491 // Add test module aliases
492 if let Some(hello_code) = entries
493 .iter()
494 .find(|(n, _)| *n == "__hello__")
495 .map(|(_, m)| m.code)
496 {
497 entries.push((
498 "__hello_alias__",
499 FrozenModule {
500 code: hello_code,
501 package: false,
502 },
503 ));
504 entries.push((
505 "__phello_alias__",
506 FrozenModule {
507 code: hello_code,
508 package: true,
509 },
510 ));
511 entries.push((
512 "__phello_alias__.spam",
513 FrozenModule {
514 code: hello_code,
515 package: false,
516 },
517 ));

Callers 1

initialize_main_vmFunction · 0.85

Calls 6

collectMethod · 0.80
mapMethod · 0.45
findMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected