From 922f69e5e2e82394bc6e82400d37d7873f4b7042 Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" Date: Sun, 18 Jan 2026 20:48:02 +0900 Subject: [PATCH] sys._jit --- Lib/test/support/__init__.py | 4 +--- crates/vm/src/stdlib/sys.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index e221ee0463..cc5a48738f 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -2783,9 +2783,7 @@ def exceeds_recursion_limit(): Py_TRACE_REFS = hasattr(sys, 'getobjects') -# XXX: RUSTPYTHON; we don't have sys._jit yet -# _JIT_ENABLED = sys._jit.is_enabled() -_JIT_ENABLED = False +_JIT_ENABLED = sys._jit.is_enabled() requires_jit_enabled = unittest.skipUnless(_JIT_ENABLED, "requires JIT enabled") requires_jit_disabled = unittest.skipIf(_JIT_ENABLED, "requires JIT disabled") diff --git a/crates/vm/src/stdlib/sys.rs b/crates/vm/src/stdlib/sys.rs index 4917e3e43c..5446b04c6d 100644 --- a/crates/vm/src/stdlib/sys.rs +++ b/crates/vm/src/stdlib/sys.rs @@ -4,6 +4,30 @@ pub(crate) use sys::{ __module_def, DOC, MAXSIZE, RUST_MULTIARCH, UnraisableHookArgsData, multiarch, }; +#[pymodule(name = "_jit")] +mod sys_jit { + /// Return True if the current Python executable supports JIT compilation, + /// and False otherwise. + #[pyfunction] + const fn is_available() -> bool { + false // RustPython has no JIT + } + + /// Return True if JIT compilation is enabled for the current Python process, + /// and False otherwise. + #[pyfunction] + const fn is_enabled() -> bool { + false // RustPython has no JIT + } + + /// Return True if the topmost Python frame is currently executing JIT code, + /// and False otherwise. + #[pyfunction] + const fn is_active() -> bool { + false // RustPython has no JIT + } +} + #[pymodule] mod sys { use crate::{ @@ -1554,9 +1578,14 @@ pub(crate) fn init_module(vm: &VirtualMachine, module: &Py, builtins: modules .set_item("builtins", builtins.to_owned().into(), vm) .unwrap(); + + // Create sys._jit submodule + let jit_module = sys_jit::make_module(vm); + extend_module!(vm, module, { "__doc__" => sys::DOC.to_owned().to_pyobject(vm), "modules" => modules, + "_jit" => jit_module, }); }