Skip to main content

sim_lib_lang_python/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3//! Thin, direct Python core profile over lowered `codec/python` expressions.
4//!
5//! This crate intentionally has no instruction format, compiler, or foreign
6//! runtime. The codec owns syntax; this profile evaluates its stable token
7//! lowering and composes the shared binding, control, mutation, sequence,
8//! dispatch, number, arena, and tracing-collector contracts.
9
10// conformance: the crate test suite checks the authorized Python library core.
11
12mod fidelity;
13mod library_core;
14mod managed;
15mod matrix_row;
16mod objects;
17mod profile;
18mod resumable;
19mod runtime;
20
21#[cfg(test)]
22mod tests;
23
24pub use fidelity::{
25    PYTHON_EVIDENCE_CASES, PYTHON_EXTERNAL_ORACLE, PYTHON_FIDELITY, PythonEvidenceCase,
26    PythonFidelity,
27};
28pub use library_core::{
29    DynamicAdmission, DynamicPython, MatchCase, MatchOutcome, PythonLibraryManifest,
30    PythonModuleAdmission, PythonModulePolicy, PythonSurface, PythonSurfaceState, match_expr,
31    python_library_manifest,
32};
33pub use managed::{PythonHeap, PythonHeapPolicy, PythonManagedKind, PythonManagedObject};
34pub use matrix_row::{python_core_matrix_row, python_core_source_cases};
35pub use objects::{
36    AttributeError, ClassError, DescriptorHook, PythonClass, PythonObjectSpace, PythonObjectValue,
37};
38pub use profile::{install_python_core_profile, python_core_profile, python_profile_symbol};
39pub use resumable::{
40    ContextManager, PythonException, PythonExceptionGroup, PythonGenerator, PythonGeneratorError,
41    PythonGeneratorStep, PythonIterator, run_with_context,
42};
43pub use runtime::{Annotation, PythonEvalPolicy, PythonFunction, PythonValue};
44
45/// Deliberately unsupported Python object and control edges.
46pub const PYTHON_OBJECT_CONTROL_GAPS: &[&str] = &[
47    "custom metaclass construction and __prepare__",
48    "dynamic descriptor protocol mutation after class creation",
49    "weak-reference callbacks and proxy objects",
50    "language-visible __del__ finalizers and resurrection",
51    "async event-loop scheduling and async-generator hooks",
52];
53
54/// A scheduler-free Python coroutine frame using the same checked send/throw
55/// transition contract as a generator.
56pub type PythonCoroutine<T, D> = PythonGenerator<T, D>;
57
58/// Cookbook recipes for this profile, embedded at build time.
59pub static RECIPES: sim_cookbook::EmbeddedDir =
60    include!(concat!(env!("OUT_DIR"), "/cookbook_recipes.rs"));