Skip to content

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Jan 18, 2026

Summary by CodeRabbit

  • New Features
    • Added sys._jit submodule with three new functions (is_available(), is_enabled(), and is_active()) to check JIT compiler status. This submodule provides standard Python interfaces for checking whether just-in-time compilation support is available, enabled, or currently active in the runtime environment. Note that JIT compilation is not supported, so all functions return false.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

A new _jit submodule is added to the Python sys module, exposing three boolean functions—is_available(), is_enabled(), and is_active()—all returning false. The module is initialized and integrated into the sys namespace.

Changes

Cohort / File(s) Summary
New _jit submodule
crates/vm/src/stdlib/sys.rs
Added new _jit submodule under sys with three const boolean functions: is_available(), is_enabled(), and is_active(), all returning false. Module is initialized and exposed in sys namespace.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A _jit module hops into place,
Three flags dancing, keeping pace,
Returning false with gentle care,
RustPython's future in the air! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'sys._jit' is minimal and vague, providing insufficient context about what the change accomplishes. Consider a more descriptive title like 'Add sys._jit module with JIT API stubs' to clearly communicate the main change to reviewers scanning the history.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youknowone youknowone marked this pull request as ready for review January 18, 2026 12:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@crates/vm/src/stdlib/sys.rs`:
- Around line 7-29: Change the is_available() implementation in the _jit module
(sys_jit::is_available) to reflect the compile-time "jit" Cargo feature instead
of always returning false; replace the constant false return with cfg!(feature =
"jit") so the function reports JIT capability based on build configuration,
while leaving is_enabled() and is_active() as false for now.

Comment on lines +7 to +29
#[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
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

echo "=== Checking root Cargo.toml for jit feature ==="
cat Cargo.toml | grep -A 50 "\[features\]" | head -60

echo ""
echo "=== Searching for rustpython-jit dependency ==="
rg 'rustpython-jit' --type toml -B 2 -A 2

echo ""
echo "=== Checking vm/Cargo.toml for jit feature ==="
fd -t f 'Cargo.toml' | xargs grep -l 'jit' 2>/dev/null

echo ""
echo "=== Checking for existing JIT implementation ==="
rg 'feature.*jit' --type rs | head -20

echo ""
echo "=== Looking at sys.rs lines 1580-1590 for integration ==="
sed -n '1575,1595p' crates/vm/src/stdlib/sys.rs

Repository: RustPython/RustPython

Length of output: 4150


🏁 Script executed:

#!/bin/bash

echo "=== Searching for cfg! usage in sys.rs ==="
rg 'cfg!' crates/vm/src/stdlib/sys.rs -A 2

echo ""
echo "=== Checking for feature-gated functions in stdlib ==="
rg '#\[cfg\(feature' crates/vm/src/stdlib/ -A 3 | head -40

echo ""
echo "=== Looking for const fn with conditional compilation ==="
rg 'const fn' crates/vm/src/ -A 3 | grep -B 1 -A 2 'cfg'

echo ""
echo "=== Checking rustpython-jit crate structure ==="
ls -la crates/jit/src/ 2>/dev/null || echo "JIT crate not found"

echo ""
echo "=== Searching for feature-gated const values in RustPython ==="
rg '#\[cfg\(' crates/vm/src/ -B 1 -A 3 | grep -A 3 'const' | head -50

Repository: RustPython/RustPython

Length of output: 5570


Well-structured JIT stub module following RustPython conventions.

The implementation correctly uses #[pymodule] and #[pyfunction] macros, and the const fn declarations are appropriate for constant return values. The docstrings align with CPython's sys._jit API.

However, given that the jit feature is defined in Cargo.toml and enables rustpython-jit, consider whether is_available() should reflect this at compile time:

#[pyfunction]
const fn is_available() -> bool {
    cfg!(feature = "jit")
}

This would accurately report JIT capability based on the build configuration, while is_enabled() and is_active() can remain false until runtime JIT activation is implemented.

🤖 Prompt for AI Agents
In `@crates/vm/src/stdlib/sys.rs` around lines 7 - 29, Change the is_available()
implementation in the _jit module (sys_jit::is_available) to reflect the
compile-time "jit" Cargo feature instead of always returning false; replace the
constant false return with cfg!(feature = "jit") so the function reports JIT
capability based on build configuration, while leaving is_enabled() and
is_active() as false for now.

@youknowone youknowone merged commit 252fa81 into RustPython:main Jan 18, 2026
13 checks passed
@youknowone youknowone deleted the sys-jit branch January 18, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant