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 function;
14mod library_core;
15mod managed;
16mod matrix_row;
17mod objects;
18mod profile;
19mod resumable;
20mod runtime;
21
22#[cfg(test)]
23mod tests;
24
25pub use fidelity::{
26    PYTHON_EVIDENCE_CASES, PYTHON_EXTERNAL_ORACLE, PYTHON_FIDELITY, PythonEvidenceCase,
27    PythonFidelity,
28};
29pub use function::{
30    PythonBodyPolicy, PythonCallError, PythonFunction, PythonFunctionFlags, PythonSignature,
31};
32pub use library_core::{
33    MatchCase, MatchOutcome, PythonLibraryManifest, PythonSurface, PythonSurfaceState,
34    dynamic_python_policy, dynamic_python_policy_with_codec, match_expr, python_library_manifest,
35    python_module_policy, python_module_policy_with_codec,
36};
37pub use managed::{
38    PythonHeap, PythonHeapExt, PythonHeapPolicy, PythonManagedKind, PythonManagedMutationError,
39    PythonManagedObject,
40};
41pub use matrix_row::{python_core_matrix_row, python_core_source_cases};
42pub use objects::{
43    AttributeError, ClassError, DescriptorHook, PythonClass, PythonObjectSpace, PythonObjectValue,
44};
45pub use profile::{install_python_core_profile, python_core_profile, python_profile_symbol};
46pub use resumable::{
47    ContextManager, PythonExceptionData, PythonExceptionError, PythonExceptionRef,
48    PythonExceptionRelation, PythonExceptions, PythonGenerator, PythonGeneratorError,
49    PythonGeneratorStep, PythonIterator, run_with_context,
50};
51pub use runtime::{Annotation, PythonEvalPolicy, PythonValue};
52
53/// Deliberately unsupported Python object and control edges.
54pub const PYTHON_OBJECT_CONTROL_GAPS: &[&str] = &[
55    "custom metaclass construction and __prepare__",
56    "dynamic descriptor protocol mutation after class creation",
57    "weak-reference callbacks and proxy objects",
58    "language-visible __del__ finalizers and resurrection",
59    "async event-loop scheduling and async-generator hooks",
60];
61
62/// A scheduler-free Python coroutine frame using the same checked send/throw
63/// transition contract as a generator.
64pub type PythonCoroutine<T, D> = PythonGenerator<T, D>;
65
66/// Cookbook recipes for this profile, embedded at build time.
67pub static RECIPES: sim_cookbook::EmbeddedDir =
68    include!(concat!(env!("OUT_DIR"), "/cookbook_recipes.rs"));