repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
linera-io/linera-protocol | https://github.com/linera-io/linera-protocol/blob/69f159d2106f7fc70870ce70074c55850bf1303b/linera-storage-service/src/common.rs | linera-storage-service/src/common.rs | // Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
use std::path::PathBuf;
use linera_base::command::resolve_binary;
use linera_views::{lru_caching::LruCachingConfig, store::KeyValueStoreError};
use serde::{Deserialize, Serialize};
use thiserror::Error;
use tonic::Status;
// The maximal bloc... | rust | Apache-2.0 | 69f159d2106f7fc70870ce70074c55850bf1303b | 2026-01-04T15:33:08.660695Z | false |
linera-io/linera-protocol | https://github.com/linera-io/linera-protocol/blob/69f159d2106f7fc70870ce70074c55850bf1303b/linera-storage-service/tests/store_test.rs | linera-storage-service/tests/store_test.rs | // Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
#![cfg(feature = "storage-service")]
use anyhow::Result;
use linera_storage_service::client::StorageServiceDatabaseInternal;
use linera_views::{
batch::Batch,
store::TestKeyValueDatabase as _,
test_utils::{
get_random_byte... | rust | Apache-2.0 | 69f159d2106f7fc70870ce70074c55850bf1303b | 2026-01-04T15:33:08.660695Z | false |
linera-io/linera-protocol | https://github.com/linera-io/linera-protocol/blob/69f159d2106f7fc70870ce70074c55850bf1303b/linera-storage-service/benches/store.rs | linera-storage-service/benches/store.rs | // Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use linera_storage_service::client::StorageServiceDatabase;
use linera_views::test_utils::performance;
use tokio::runtime::Runtime;
fn bench_storage_service(criterion: &m... | rust | Apache-2.0 | 69f159d2106f7fc70870ce70074c55850bf1303b | 2026-01-04T15:33:08.660695Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/build.rs | build.rs | fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
println!("cargo:rerun-if-changed=logo.ico");
let mut res = winresource::WindowsResource::new();
if std::path::Path::new("logo.ico").exists() {
res.set_icon("logo.ico");
} else {
printl... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/example_projects/wasm32_without_js/rustpython-without-js/src/lib.rs | example_projects/wasm32_without_js/rustpython-without-js/src/lib.rs | use rustpython_vm::{Interpreter};
unsafe extern "C" {
fn kv_get(kp: i32, kl: i32, vp: i32, vl: i32) -> i32;
/// kp and kl are the key pointer and length in wasm memory, vp and vl are for the value
fn kv_put(kp: i32, kl: i32, vp: i32, vl: i32) -> i32;
fn print(p: i32, l: i32) -> i32;
}
#[unsafe(no_ma... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/example_projects/wasm32_without_js/wasm-runtime/src/main.rs | example_projects/wasm32_without_js/wasm-runtime/src/main.rs | use std::collections::HashMap;
use wasmer::{
Function, FunctionEnv, FunctionEnvMut, Instance, Memory, Module, Store, Value, imports,
};
struct Ctx {
kv: HashMap<Vec<u8>, Vec<u8>>,
mem: Option<Memory>,
}
/// kp and kl are the key pointer and length in wasm memory, vp and vl are for the return value
/// if ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/example_projects/barebone/src/main.rs | example_projects/barebone/src/main.rs | use rustpython_vm::Interpreter;
pub fn main() {
let interp = Interpreter::without_stdlib(Default::default());
let value = interp.enter(|vm| {
let max = vm.builtins.get_attr("max", vm)?;
let value = max.call((vm.ctx.new_int(5), vm.ctx.new_int(10)), vm)?;
vm.print((vm.ctx.new_str("python ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/example_projects/frozen_stdlib/src/main.rs | example_projects/frozen_stdlib/src/main.rs | // spell-checker:ignore aheui
/// Setting up a project with a frozen stdlib can be done *either* by using `rustpython::InterpreterConfig` or `rustpython_vm::Interpreter::with_init`.
/// See each function for example.
///
/// See also: `aheui-rust.md` for freezing your own package.
use rustpython_vm::{PyResult, Virtua... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/src/settings.rs | src/settings.rs | use lexopt::Arg::*;
use lexopt::ValueExt;
use rustpython_vm::{Settings, vm::CheckHashPycsMode};
use std::str::FromStr;
use std::{cmp, env};
pub enum RunMode {
Script(String),
Command(String),
Module(String),
InstallPip(InstallPipMode),
Repl,
}
pub enum InstallPipMode {
/// Install pip using th... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/src/lib.rs | src/lib.rs | //! This is the `rustpython` binary. If you're looking to embed RustPython into your application,
//! you're likely looking for the [`rustpython_vm`] crate.
//!
//! You can install `rustpython` with `cargo install rustpython`, or if you'd like to inject your
//! own native modules you can make a binary crate that depen... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/src/shell.rs | src/shell.rs | mod helper;
use rustpython_compiler::{
CompileError, ParseError, parser::InterpolatedStringErrorType, parser::LexicalErrorType,
parser::ParseErrorType,
};
use rustpython_vm::{
AsObject, PyResult, VirtualMachine,
builtins::PyBaseExceptionRef,
compiler::{self},
readline::{Readline, ReadlineResult... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/src/interpreter.rs | src/interpreter.rs | use rustpython_vm::{Interpreter, PyRef, Settings, VirtualMachine, builtins::PyModule};
pub type InitHook = Box<dyn FnOnce(&mut VirtualMachine)>;
/// The convenient way to create [rustpython_vm::Interpreter] with stdlib and other stuffs.
///
/// Basic usage:
/// ```
/// let interpreter = rustpython::InterpreterConfig:... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/src/main.rs | src/main.rs | pub fn main() -> std::process::ExitCode {
rustpython::run(|_vm| {})
}
| rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/src/shell/helper.rs | src/shell/helper.rs | #![cfg_attr(target_arch = "wasm32", allow(dead_code))]
use rustpython_vm::{
AsObject, PyResult, TryFromObject, VirtualMachine,
builtins::{PyDictRef, PyStrRef},
function::ArgIterable,
identifier,
};
pub struct ShellHelper<'vm> {
vm: &'vm VirtualMachine,
globals: PyDictRef,
}
fn reverse_string(s... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/benches/microbenchmarks.rs | benches/microbenchmarks.rs | use criterion::{
BatchSize, BenchmarkGroup, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main,
measurement::WallTime,
};
use pyo3::types::PyAnyMethods;
use rustpython_compiler::Mode;
use rustpython_vm::{AsObject, Interpreter, PyResult, Settings};
use std::{
fs, io,
path::{Path, PathBuf... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/benches/execution.rs | benches/execution.rs | use criterion::{
Bencher, BenchmarkGroup, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main,
measurement::WallTime,
};
use rustpython_compiler::Mode;
use rustpython_vm::{Interpreter, PyResult, Settings};
use std::{collections::HashMap, hint::black_box, path::Path};
fn bench_cpython_code(b: &m... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wtf8/src/lib.rs | crates/wtf8/src/lib.rs | // spell-checker:disable
//! An implementation of [WTF-8], a utf8-compatible encoding that allows for
//! unpaired surrogate codepoints. This implementation additionally allows for
//! paired surrogates that are nonetheless treated as two separate codepoints.
//!
//!
//! RustPython uses this because CPython internally... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | true |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wtf8/src/core_char.rs | crates/wtf8/src/core_char.rs | // spell-checker:disable
//! Unstable functions from [`core::char`]
use core::slice;
pub const MAX_LEN_UTF8: usize = 4;
pub const MAX_LEN_UTF16: usize = 2;
// UTF-8 ranges and tags for encoding characters
const TAG_CONT: u8 = 0b1000_0000;
const TAG_TWO_B: u8 = 0b1100_0000;
const TAG_THREE_B: u8 = 0b1110_0000;
const ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wtf8/src/core_str_count.rs | crates/wtf8/src/core_str_count.rs | // spell-checker:disable
//! Modified from core::str::count
use super::Wtf8;
const USIZE_SIZE: usize = core::mem::size_of::<usize>();
const UNROLL_INNER: usize = 4;
#[inline]
pub(super) fn count_chars(s: &Wtf8) -> usize {
if s.len() < USIZE_SIZE * UNROLL_INNER {
// Avoid entering the optimized implementa... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wtf8/src/core_str.rs | crates/wtf8/src/core_str.rs | //! Operations related to UTF-8 validation.
//!
//! Copied from `core::str::validations`
/// Returns the initial codepoint accumulator for the first byte.
/// The first byte is special, only want bottom 5 bits for width 2, 4 bits
/// for width 3, and 3 bits for width 4.
#[inline]
const fn utf8_first_byte(byte: u8, wid... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/src/lib.rs | crates/jit/src/lib.rs | mod instructions;
extern crate alloc;
use alloc::fmt;
use core::mem::ManuallyDrop;
use cranelift::prelude::*;
use cranelift_jit::{JITBuilder, JITModule};
use cranelift_module::{FuncId, Linkage, Module, ModuleError};
use instructions::FunctionCompiler;
use rustpython_compiler_core::bytecode;
#[derive(Debug, thiserror... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/src/instructions.rs | crates/jit/src/instructions.rs | // spell-checker: disable
use super::{JitCompileError, JitSig, JitType};
use cranelift::codegen::ir::FuncRef;
use cranelift::prelude::*;
use num_traits::cast::ToPrimitive;
use rustpython_compiler_core::bytecode::{
self, BinaryOperator, BorrowedConstant, CodeObject, ComparisonOperator, Instruction, Label,
OpArg,... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | true |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/tests/float_tests.rs | crates/jit/tests/float_tests.rs | macro_rules! assert_approx_eq {
($left:expr, $right:expr) => {
match ($left, $right) {
(Ok(lhs), Ok(rhs)) => approx::assert_relative_eq!(lhs, rhs),
(lhs, rhs) => assert_eq!(lhs, rhs),
}
};
}
macro_rules! assert_bits_eq {
($left:expr, $right:expr) => {
match (... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/tests/lib.rs | crates/jit/tests/lib.rs | #[macro_use]
mod common;
mod bool_tests;
mod float_tests;
mod int_tests;
mod misc_tests;
mod none_tests;
| rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/tests/none_tests.rs | crates/jit/tests/none_tests.rs | #[test]
fn test_not() {
let not_ = jit_function! { not_(x: i64) -> bool => r##"
def not_(x: int):
return not None
"## };
assert_eq!(not_(0), Ok(true));
}
#[test]
fn test_if_not() {
let if_not = jit_function! { if_not(x: i64) -> i64 => r##"
def if_not(x: int):
if... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/tests/common.rs | crates/jit/tests/common.rs | use core::ops::ControlFlow;
use rustpython_compiler_core::bytecode::{
CodeObject, ConstantData, Instruction, OpArg, OpArgState,
};
use rustpython_jit::{CompiledCode, JitType};
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Function {
code: Box<CodeObject>,
annotations: HashMap<String, St... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/tests/misc_tests.rs | crates/jit/tests/misc_tests.rs | use rustpython_jit::{AbiValue, JitArgumentError};
// TODO currently broken
// #[test]
// fn test_no_return_value() {
// let func = jit_function! { func() => r##"
// def func():
// pass
// "## };
//
// assert_eq!(func(), Ok(()));
// }
#[test]
fn test_invoke() {
let func = jit_functi... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/tests/bool_tests.rs | crates/jit/tests/bool_tests.rs | #[test]
fn test_return() {
let return_ = jit_function! { return_(a: bool) -> bool => r##"
def return_(a: bool):
return a
"## };
assert_eq!(return_(true), Ok(true));
assert_eq!(return_(false), Ok(false));
}
#[test]
fn test_const() {
let const_true = jit_function! { const_true(a:... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/jit/tests/int_tests.rs | crates/jit/tests/int_tests.rs | use core::f64;
#[test]
fn test_add() {
let add = jit_function! { add(a:i64, b:i64) -> i64 => r##"
def add(a: int, b: int):
return a + b
"## };
assert_eq!(add(5, 10), Ok(15));
assert_eq!(add(-5, 12), Ok(7));
assert_eq!(add(-5, -3), Ok(-8));
}
#[test]
fn test_sub() {
let sub... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/codegen/src/lib.rs | crates/codegen/src/lib.rs | //! Compile a Python AST or source code into bytecode consumable by RustPython.
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/main/logo.png")]
#![doc(html_root_url = "https://docs.rs/rustpython-compiler/")]
#[macro_use]
extern crate log;
extern crate alloc;
type IndexMap<K, V> = ind... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/codegen/src/symboltable.rs | crates/codegen/src/symboltable.rs | /* Python code is pre-scanned for symbols in the ast.
This ensures that global and nonlocal keywords are picked up.
Then the compiler can use the symbol table to generate proper
load and store instructions for names.
Inspirational file: https://github.com/python/cpython/blob/main/Python/symtable.c
*/
use crate::{
... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | true |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/codegen/src/compile.rs | crates/codegen/src/compile.rs | //!
//! Take an AST and transform it into bytecode
//!
//! Inspirational code:
//! <https://github.com/python/cpython/blob/main/Python/compile.c>
//! <https://github.com/micropython/micropython/blob/master/py/compile.c>
// spell-checker:ignore starunpack subscripter
#![deny(clippy::cast_possible_truncation)]
use... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | true |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/codegen/src/string_parser.rs | crates/codegen/src/string_parser.rs | //! A stripped-down version of ruff's string literal parser, modified to
//! handle surrogates in string literals and output WTF-8.
//!
//! Any `unreachable!()` statements in this file are because we only get here
//! after ruff has already successfully parsed the string literal, meaning
//! we don't need to do any val... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/codegen/src/error.rs | crates/codegen/src/error.rs | use alloc::fmt;
use core::fmt::Display;
use rustpython_compiler_core::SourceLocation;
use thiserror::Error;
#[derive(Debug)]
pub enum PatternUnreachableReason {
NameCapture,
Wildcard,
}
impl Display for PatternUnreachableReason {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match sel... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/codegen/src/unparse.rs | crates/codegen/src/unparse.rs | use alloc::fmt;
use core::fmt::Display as _;
use ruff_python_ast::{
self as ruff, Arguments, BoolOp, Comprehension, ConversionFlag, Expr, Identifier, Operator,
Parameter, ParameterWithDefault, Parameters,
};
use ruff_text_size::Ranged;
use rustpython_compiler_core::SourceFile;
use rustpython_literal::escape::{A... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/codegen/src/ir.rs | crates/codegen/src/ir.rs | use core::ops;
use crate::{IndexMap, IndexSet, error::InternalError};
use rustpython_compiler_core::{
OneIndexed, SourceLocation,
bytecode::{
CodeFlags, CodeObject, CodeUnit, CodeUnits, ConstantData, ExceptionTableEntry,
InstrDisplayContext, Instruction, Label, OpArg, PyCodeLocationInfoKind,
... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/pylib/build.rs | crates/pylib/build.rs | const CRATE_ROOT: &str = "../..";
fn main() {
process_python_libs(format!("{CRATE_ROOT}/vm/Lib/python_builtins/*").as_str());
process_python_libs(format!("{CRATE_ROOT}/vm/Lib/core_modules/*").as_str());
#[cfg(feature = "freeze-stdlib")]
if cfg!(windows) {
process_python_libs(format!("{CRATE_RO... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/pylib/src/lib.rs | crates/pylib/src/lib.rs | //! This crate includes the compiled python bytecode of the RustPython standard library. The most
//! common way to use this crate is to just add the `"freeze-stdlib"` feature to `rustpython-vm`,
//! in order to automatically include the python part of the standard library into the binary.
// windows needs to read the... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wasm/src/browser_module.rs | crates/wasm/src/browser_module.rs | use rustpython_vm::VirtualMachine;
pub(crate) use _browser::make_module;
#[pymodule]
mod _browser {
use crate::{convert, js_module::PyPromise, vm_class::weak_vm, wasm_builtins::window};
use js_sys::Promise;
use rustpython_vm::{
PyObjectRef, PyPayload, PyRef, PyResult, VirtualMachine,
built... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wasm/src/lib.rs | crates/wasm/src/lib.rs | extern crate alloc;
pub mod browser_module;
pub mod convert;
pub mod js_module;
pub mod vm_class;
pub mod wasm_builtins;
#[macro_use]
extern crate rustpython_vm;
use js_sys::{Reflect, WebAssembly::RuntimeError};
use std::panic;
pub use vm_class::add_init_func;
pub(crate) use vm_class::weak_vm;
use wasm_bindgen::prel... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wasm/src/convert.rs | crates/wasm/src/convert.rs | #![allow(clippy::empty_docs)] // TODO: remove it later. false positive by wasm-bindgen generated code
use crate::js_module;
use crate::vm_class::{WASMVirtualMachine, stored_vm_from_wasm};
use js_sys::{Array, ArrayBuffer, Object, Promise, Reflect, SyntaxError, Uint8Array};
use rustpython_vm::{
AsObject, Py, PyObjec... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wasm/src/wasm_builtins.rs | crates/wasm/src/wasm_builtins.rs | //! Builtin function specific to WASM build.
//!
//! This is required because some feature like I/O works differently in the browser comparing to
//! desktop.
//! Implements functions listed here: https://docs.python.org/3/library/builtins.html.
use rustpython_vm::{PyObjectRef, PyRef, PyResult, VirtualMachine, builtin... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wasm/src/js_module.rs | crates/wasm/src/js_module.rs | pub(crate) use _js::{PyJsValue, PyPromise};
use rustpython_vm::VirtualMachine;
#[pymodule]
mod _js {
use crate::{
convert,
vm_class::{WASMVirtualMachine, stored_vm_from_wasm},
weak_vm,
};
use core::{cell, fmt, future};
use js_sys::{Array, Object, Promise, Reflect};
use rustp... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/wasm/src/vm_class.rs | crates/wasm/src/vm_class.rs | use crate::{
browser_module::setup_browser_module,
convert::{self, PyResultExt},
js_module, wasm_builtins,
};
use alloc::rc::{Rc, Weak};
use core::cell::RefCell;
use js_sys::{Object, TypeError};
use rustpython_vm::{
Interpreter, PyObjectRef, PyPayload, PyRef, PyResult, Settings, VirtualMachine,
buil... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/static_cell.rs | crates/common/src/static_cell.rs | #[cfg(not(feature = "threading"))]
mod non_threading {
use crate::lock::OnceCell;
use std::thread::LocalKey;
pub struct StaticCell<T: 'static> {
inner: &'static LocalKey<OnceCell<&'static T>>,
}
fn leak<T>(x: T) -> &'static T {
Box::leak(Box::new(x))
}
impl<T> StaticCell<T... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/cformat.rs | crates/common/src/cformat.rs | //! Implementation of Printf-Style string formatting
//! as per the [Python Docs](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting).
use alloc::fmt;
use bitflags::bitflags;
use core::{
cmp,
iter::{Enumerate, Peekable},
str::FromStr,
};
use itertools::Itertools;
use malachite_bi... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | true |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/borrow.rs | crates/common/src/borrow.rs | use crate::lock::{
MapImmutable, PyImmutableMappedMutexGuard, PyMappedMutexGuard, PyMappedRwLockReadGuard,
PyMappedRwLockWriteGuard, PyMutexGuard, PyRwLockReadGuard, PyRwLockWriteGuard,
};
use alloc::fmt;
use core::ops::{Deref, DerefMut};
macro_rules! impl_from {
($lt:lifetime, $gen:ident, $t:ty, $($var:id... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/lib.rs | crates/common/src/lib.rs | //! A crate to hold types and functions common to all rustpython components.
#![cfg_attr(all(target_os = "wasi", target_env = "p2"), feature(wasip2))]
extern crate alloc;
#[macro_use]
mod macros;
pub use macros::*;
pub mod atomic;
pub mod borrow;
pub mod boxvec;
pub mod cformat;
#[cfg(any(unix, windows, target_os =... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/float_ops.rs | crates/common/src/float_ops.rs | use malachite_bigint::{BigInt, ToBigInt};
use num_traits::{Float, Signed, ToPrimitive, Zero};
use std::f64;
pub const fn decompose_float(value: f64) -> (f64, i32) {
if 0.0 == value {
(0.0, 0i32)
} else {
let bits = value.to_bits();
let exponent: i32 = ((bits >> 52) & 0x7ff) as i32 - 102... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/os.rs | crates/common/src/os.rs | // spell-checker:disable
// TODO: we can move more os-specific bindings/interfaces from stdlib::{os, posix, nt} to here
use core::str::Utf8Error;
use std::{io, process::ExitCode};
/// Convert exit code to std::process::ExitCode
///
/// On Windows, this supports the full u32 range including STATUS_CONTROL_C_EXIT (0xC0... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/lock.rs | crates/common/src/lock.rs | //! A module containing [`lock_api`]-based lock types that are or are not `Send + Sync`
//! depending on whether the `threading` feature of this module is enabled.
use lock_api::{
MappedMutexGuard, MappedRwLockReadGuard, MappedRwLockWriteGuard, Mutex, MutexGuard, RwLock,
RwLockReadGuard, RwLockUpgradableReadGu... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/boxvec.rs | crates/common/src/boxvec.rs | // spell-checker:disable
//! An unresizable vector backed by a `Box<[T]>`
#![allow(clippy::needless_lifetimes)]
use alloc::{fmt, slice};
use core::{
borrow::{Borrow, BorrowMut},
cmp,
mem::{self, MaybeUninit},
ops::{Bound, Deref, DerefMut, RangeBounds},
ptr,
};
pub struct BoxVec<T> {
xs: Box<[M... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/rand.rs | crates/common/src/rand.rs | /// Get `N` bytes of random data.
///
/// This function is mildly expensive to call, as it fetches random data
/// directly from the OS entropy source.
///
/// # Panics
///
/// Panics if the OS entropy source returns an error.
pub fn os_random<const N: usize>() -> [u8; N] {
let mut buf = [0u8; N];
getrandom::fi... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/macros.rs | crates/common/src/macros.rs | /// Suppress the MSVC invalid parameter handler, which by default crashes the process. Does nothing
/// on non-MSVC targets.
#[macro_export]
macro_rules! suppress_iph {
($e:expr) => {
$crate::__suppress_iph_impl!($e)
};
}
#[macro_export]
#[doc(hidden)]
#[cfg(all(windows, target_env = "msvc"))]
macro_ru... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/windows.rs | crates/common/src/windows.rs | use rustpython_wtf8::Wtf8;
use std::{
ffi::{OsStr, OsString},
os::windows::ffi::{OsStrExt, OsStringExt},
};
/// _MAX_ENV from Windows CRT stdlib.h - maximum environment variable size
pub const _MAX_ENV: usize = 32767;
pub trait ToWideString {
fn to_wide(&self) -> Vec<u16>;
fn to_wide_with_nul(&self) -... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/rc.rs | crates/common/src/rc.rs | #[cfg(not(feature = "threading"))]
use alloc::rc::Rc;
#[cfg(feature = "threading")]
use alloc::sync::Arc;
// type aliases instead of new-types because you can't do `fn method(self: PyRc<Self>)` with a
// newtype; requires the arbitrary_self_types unstable feature
#[cfg(feature = "threading")]
pub type PyRc<T> = Arc<T... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/crt_fd.rs | crates/common/src/crt_fd.rs | //! A module implementing an io type backed by the C runtime's file descriptors, i.e. what's
//! returned from libc::open, even on windows.
use alloc::fmt;
use core::cmp;
use std::{ffi, io};
#[cfg(not(windows))]
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
#[cfg(windows)]
use st... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/format.rs | crates/common/src/format.rs | // spell-checker:ignore ddfe
use core::ops::Deref;
use core::{cmp, str::FromStr};
use itertools::{Itertools, PeekingNext};
use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_bigint::{BigInt, Sign};
use num_complex::Complex64;
use num_traits::FromPrimitive;
use num_traits::{Signed, cast::ToPrimitive};... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | true |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/hash.rs | crates/common/src/hash.rs | use core::hash::{BuildHasher, Hash, Hasher};
use malachite_bigint::BigInt;
use num_traits::ToPrimitive;
use siphasher::sip::SipHasher24;
pub type PyHash = i64;
pub type PyUHash = u64;
/// A PyHash value used to represent a missing hash value, e.g. means "not yet computed" for
/// `str`'s hash cache
pub const SENTINEL... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/linked_list.rs | crates/common/src/linked_list.rs | // spell-checker:disable
//! This module is modified from tokio::util::linked_list: <https://github.com/tokio-rs/tokio/blob/master/tokio/src/util/linked_list.rs>
//! Tokio is licensed under the MIT license:
//!
//! Copyright (c) 2021 Tokio Contributors
//!
//! Permission is hereby granted, free of charge, to any
//! p... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/int.rs | crates/common/src/int.rs | use malachite_base::{num::conversion::traits::RoundingInto, rounding_modes::RoundingMode};
use malachite_bigint::{BigInt, BigUint, Sign};
use malachite_q::Rational;
use num_traits::{One, ToPrimitive, Zero};
pub fn true_div(numerator: &BigInt, denominator: &BigInt) -> f64 {
let rational = Rational::from_integers_re... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/atomic.rs | crates/common/src/atomic.rs | use core::ptr::{self, NonNull};
pub use core::sync::atomic::*;
pub use radium::Radium;
mod sealed {
pub trait Sealed {}
}
pub trait PyAtomicScalar: sealed::Sealed {
type Radium: Radium<Item = Self>;
}
pub type PyAtomic<T> = <T as PyAtomicScalar>::Radium;
#[cfg(feature = "threading")]
macro_rules! atomic_ty {... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/str.rs | crates/common/src/str.rs | // spell-checker:ignore uncomputed
use crate::atomic::{PyAtomic, Radium};
use crate::format::CharLen;
use crate::wtf8::{CodePoint, Wtf8, Wtf8Buf};
use ascii::{AsciiChar, AsciiStr, AsciiString};
use core::fmt;
use core::ops::{Bound, RangeBounds};
use core::sync::atomic::Ordering::Relaxed;
#[cfg(not(target_arch = "wasm3... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/refcount.rs | crates/common/src/refcount.rs | use crate::atomic::{Ordering::*, PyAtomic, Radium};
/// from alloc::sync
/// A soft limit on the amount of references that may be made to an `Arc`.
///
/// Going above this limit will abort your program (although not
/// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references.
const MAX_REFCOUNT: usize = isize::MAX as... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/fileutils.rs | crates/common/src/fileutils.rs | // Python/fileutils.c in CPython
#![allow(non_snake_case)]
#[cfg(not(windows))]
pub use libc::stat as StatStruct;
#[cfg(windows)]
pub use windows::{StatStruct, fstat};
#[cfg(not(windows))]
pub fn fstat(fd: crate::crt_fd::Borrowed<'_>) -> std::io::Result<StatStruct> {
let mut stat = core::mem::MaybeUninit::uninit... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/encodings.rs | crates/common/src/encodings.rs | use core::ops::{self, Range};
use num_traits::ToPrimitive;
use crate::str::StrKind;
use crate::wtf8::{CodePoint, Wtf8, Wtf8Buf};
pub trait StrBuffer: AsRef<Wtf8> {
fn is_compatible_with(&self, kind: StrKind) -> bool {
let s = self.as_ref();
match kind {
StrKind::Ascii => s.is_ascii(),... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/lock/thread_mutex.rs | crates/common/src/lock/thread_mutex.rs | #![allow(clippy::needless_lifetimes)]
use alloc::fmt;
use core::{
cell::UnsafeCell,
marker::PhantomData,
ops::{Deref, DerefMut},
ptr::NonNull,
sync::atomic::{AtomicUsize, Ordering},
};
use lock_api::{GetThreadId, GuardNoSend, RawMutex};
// based off ReentrantMutex from lock_api
/// A mutex type t... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/lock/immutable_mutex.rs | crates/common/src/lock/immutable_mutex.rs | #![allow(clippy::needless_lifetimes)]
use alloc::fmt;
use core::{marker::PhantomData, ops::Deref};
use lock_api::{MutexGuard, RawMutex};
/// A mutex guard that has an exclusive lock, but only an immutable reference; useful if you
/// need to map a mutex guard with a function that returns an `&T`. Construct using the
... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/common/src/lock/cell_lock.rs | crates/common/src/lock/cell_lock.rs | // spell-checker:ignore upgradably sharedly
use core::{cell::Cell, num::NonZero};
use lock_api::{
GetThreadId, RawMutex, RawRwLock, RawRwLockDowngrade, RawRwLockRecursive, RawRwLockUpgrade,
RawRwLockUpgradeDowngrade,
};
pub struct RawCellMutex {
locked: Cell<bool>,
}
unsafe impl RawMutex for RawCellMutex ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/pytraverse.rs | crates/derive-impl/src/pytraverse.rs | use proc_macro2::TokenStream;
use quote::quote;
use syn::{Attribute, DeriveInput, Field, Result};
struct TraverseAttr {
/// set to `true` if the attribute is `#[pytraverse(skip)]`
skip: bool,
}
const ATTR_TRAVERSE: &str = "pytraverse";
/// only accept `#[pytraverse(skip)]` for now
fn pytraverse_arg(attr: &At... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/pymodule.rs | crates/derive-impl/src/pymodule.rs | use crate::error::Diagnostic;
use crate::pystructseq::PyStructSequenceMeta;
use crate::util::{
ALL_ALLOWED_NAMES, AttrItemMeta, AttributeExt, ClassItemMeta, ContentItem, ContentItemInner,
ErrorVec, ItemMeta, ItemNursery, ModuleItemMeta, SimpleItemMeta, format_doc, iter_use_idents,
pyclass_ident_and_attrs, t... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/lib.rs | crates/derive-impl/src/lib.rs | #![recursion_limit = "128"]
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/main/logo.png")]
#![doc(html_root_url = "https://docs.rs/rustpython-derive/")]
extern crate proc_macro;
#[macro_use]
extern crate maplit;
#[macro_use]
mod error;
#[macro_use]
mod util;
mod compile_bytecode;
m... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/compile_bytecode.rs | crates/derive-impl/src/compile_bytecode.rs | //! Parsing and processing for this form:
//! ```ignore
//! py_compile!(
//! // either:
//! source = "python_source_code",
//! // or
//! file = "file/path/relative/to/$CARGO_MANIFEST_DIR",
//!
//! // the mode to compile the code in
//! mode = "exec", // or "eval" or "single"
//! // the path ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/pystructseq.rs | crates/derive-impl/src/pystructseq.rs | use crate::util::{ItemMeta, ItemMetaInner};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::{DeriveInput, Ident, Item, Result};
use syn_ext::ext::{AttributeExt, GetIdent};
use syn_ext::types::{Meta, PunctuatedNestedMeta};
// #[pystruct_sequence_data] - For Data structs
/// Field kind for stru... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/from_args.rs | crates/derive-impl/src/from_args.rs | use proc_macro2::TokenStream;
use quote::{ToTokens, quote};
use syn::ext::IdentExt;
use syn::meta::ParseNestedMeta;
use syn::{Attribute, Data, DeriveInput, Expr, Field, Ident, Result, Token, parse_quote};
/// The kind of the python parameter, this corresponds to the value of Parameter.kind
/// (https://docs.python.org... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/error.rs | crates/derive-impl/src/error.rs | // Taken from https://github.com/rustwasm/wasm-bindgen/blob/master/crates/backend/src/error.rs
//
// Copyright (c) 2014 Alex Crichton
//
// Permission is hereby granted, free of charge, to any
// person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the
// Software ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/util.rs | crates/derive-impl/src/util.rs | use itertools::Itertools;
use proc_macro2::{Span, TokenStream};
use quote::{ToTokens, quote};
use std::collections::{HashMap, HashSet};
use syn::{Attribute, Ident, Result, Signature, UseTree, spanned::Spanned};
use syn_ext::{
ext::{AttributeExt as SynAttributeExt, *},
types::*,
};
pub(crate) const ALL_ALLOWED_... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/pyclass.rs | crates/derive-impl/src/pyclass.rs | use super::Diagnostic;
use crate::util::{
ALL_ALLOWED_NAMES, ClassItemMeta, ContentItem, ContentItemInner, ErrorVec, ExceptionItemMeta,
ItemMeta, ItemMetaInner, ItemNursery, SimpleItemMeta, format_doc, pyclass_ident_and_attrs,
pyexception_ident_and_attrs, text_signature,
};
use core::str::FromStr;
use proc_... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | true |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/derive-impl/src/pypayload.rs | crates/derive-impl/src/pypayload.rs | use proc_macro2::TokenStream;
use quote::quote;
use syn::{DeriveInput, Result};
pub(crate) fn impl_pypayload(input: DeriveInput) -> Result<TokenStream> {
let ty = &input.ident;
let ret = quote! {
impl ::rustpython_vm::PyPayload for #ty {
#[inline]
fn class(_ctx: &::rustpython_v... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/compiler-source/src/lib.rs | crates/compiler-source/src/lib.rs | pub use ruff_source_file::{LineIndex, OneIndexed as LineNumber, PositionEncoding, SourceLocation};
use ruff_text_size::TextRange;
pub use ruff_text_size::TextSize;
#[derive(Clone)]
pub struct SourceCode<'src> {
pub path: &'src str,
pub text: &'src str,
pub index: LineIndex,
}
impl<'src> SourceCode<'src> {... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/compiler-core/src/frozen.rs | crates/compiler-core/src/frozen.rs | use crate::bytecode::*;
use crate::marshal::{self, Read, ReadBorrowed, Write};
/// A frozen module. Holds a frozen code object and whether it is part of a package
#[derive(Copy, Clone)]
pub struct FrozenModule<B = &'static [u8]> {
pub code: FrozenCodeObject<B>,
pub package: bool,
}
#[derive(Copy, Clone)]
pub ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/compiler-core/src/lib.rs | crates/compiler-core/src/lib.rs | #![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/main/logo.png")]
#![doc(html_root_url = "https://docs.rs/rustpython-compiler-core/")]
extern crate alloc;
pub mod bytecode;
pub mod frozen;
pub mod marshal;
mod mode;
pub mod varint;
pub use mode::Mode;
pub use ruff_source_file::{
L... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/compiler-core/src/marshal.rs | crates/compiler-core/src/marshal.rs | use crate::{OneIndexed, SourceLocation, bytecode::*};
use core::convert::Infallible;
use malachite_bigint::{BigInt, Sign};
use num_complex::Complex64;
use rustpython_wtf8::Wtf8;
pub const FORMAT_VERSION: u32 = 4;
#[derive(Debug)]
pub enum MarshalError {
/// Unexpected End Of File
Eof,
/// Invalid Bytecode... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/compiler-core/src/bytecode.rs | crates/compiler-core/src/bytecode.rs | //! Implement python as a virtual machine with bytecode. This module
//! implements bytecode structure.
use crate::{
marshal::MarshalError,
varint::{read_varint, read_varint_with_start, write_varint, write_varint_with_start},
{OneIndexed, SourceLocation},
};
use alloc::{collections::BTreeSet, fmt, vec::Vec... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | true |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/compiler-core/src/mode.rs | crates/compiler-core/src/mode.rs | #[derive(Clone, Copy)]
pub enum Mode {
Exec,
Eval,
Single,
/// Returns the value of the last statement in the statement list.
BlockExpr,
}
impl core::str::FromStr for Mode {
type Err = ModeParseError;
// To support `builtins.compile()` `mode` argument
fn from_str(s: &str) -> Result<Sel... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/compiler-core/src/varint.rs | crates/compiler-core/src/varint.rs | //! Variable-length integer encoding utilities.
//!
//! Uses 6-bit chunks with a continuation bit (0x40) to encode integers.
//! Used for exception tables and line number tables.
/// Write a variable-length unsigned integer using 6-bit chunks.
/// Returns the number of bytes written.
#[inline]
pub fn write_varint(buf:... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/build.rs | crates/vm/build.rs | use itertools::Itertools;
use std::{env, io::prelude::*, path::PathBuf, process::Command};
fn main() {
let frozen_libs = if cfg!(feature = "freeze-stdlib") {
"Lib/*/*.py"
} else {
"Lib/python_builtins/*.py"
};
for entry in glob::glob(frozen_libs).expect("Lib/ exists?").flatten() {
... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/coroutine.rs | crates/vm/src/coroutine.rs | use crate::{
AsObject, Py, PyObject, PyObjectRef, PyResult, VirtualMachine,
builtins::{PyBaseExceptionRef, PyStrRef},
common::lock::PyMutex,
exceptions::types::PyBaseException,
frame::{ExecutionResult, FrameRef},
function::OptionalArg,
protocol::PyIterReturn,
};
use crossbeam_utils::atomic::... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/cformat.rs | crates/vm/src/cformat.rs | //cspell:ignore bytesobject
//! Implementation of Printf-Style string formatting
//! as per the [Python Docs](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting).
use crate::common::cformat::*;
use crate::common::wtf8::{CodePoint, Wtf8, Wtf8Buf};
use crate::{
AsObject, PyObject, PyObje... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/anystr.rs | crates/vm/src/anystr.rs | use crate::{
Py, PyObject, PyObjectRef, PyResult, TryFromObject, VirtualMachine,
builtins::{PyIntRef, PyTuple},
convert::TryFromBorrowedObject,
function::OptionalOption,
};
use num_traits::{cast::ToPrimitive, sign::Signed};
use core::ops::Range;
#[derive(FromArgs)]
pub struct SplitArgs<T: TryFromObjec... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/sequence.rs | crates/vm/src/sequence.rs | use crate::{
AsObject, PyObject, PyObjectRef, PyResult,
builtins::PyIntRef,
function::OptionalArg,
sliceable::SequenceIndexOp,
types::PyComparisonOp,
vm::{MAX_MEMORY_SIZE, VirtualMachine},
};
use core::ops::{Deref, Range};
use optional::Optioned;
pub trait MutObjectSequenceOp {
type Inner: ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/prelude.rs | crates/vm/src/prelude.rs | //! The prelude imports the various objects and traits.
//!
//! The intention is that one can include `use rustpython_vm::prelude::*`.
pub use crate::{
object::{
AsObject, Py, PyExact, PyObject, PyObjectRef, PyPayload, PyRef, PyRefExact, PyResult,
PyWeakRef,
},
vm::{Context, Interpreter, Se... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/warn.rs | crates/vm/src/warn.rs | use crate::{
AsObject, Context, Py, PyObject, PyObjectRef, PyResult, VirtualMachine,
builtins::{
PyDictRef, PyListRef, PyStr, PyStrInterned, PyStrRef, PyTuple, PyTupleRef, PyTypeRef,
},
convert::{IntoObject, TryFromObject},
types::PyComparisonOp,
};
pub struct WarningsState {
filters: P... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/lib.rs | crates/vm/src/lib.rs | //! This crate contains most of the python logic.
//!
//! - Interpreter
//! - Import mechanics
//! - Base objects
//!
//! Some stdlib modules are implemented here, but most of them are in the `rustpython-stdlib` module. The
// to allow `mod foo {}` in foo.rs; clippy thinks this is a mistake/misunderstanding of
// how ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/version.rs | crates/vm/src/version.rs | //! Several function to retrieve version information.
use chrono::{Local, prelude::DateTime};
use core::time::Duration;
use std::time::UNIX_EPOCH;
// = 3.13.0alpha
pub const MAJOR: usize = 3;
pub const MINOR: usize = 13;
pub const MICRO: usize = 0;
pub const RELEASELEVEL: &str = "alpha";
pub const RELEASELEVEL_N: usi... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/byte.rs | crates/vm/src/byte.rs | //! byte operation APIs
use crate::object::AsObject;
use crate::{PyObject, PyResult, VirtualMachine};
use num_traits::ToPrimitive;
pub fn bytes_from_object(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Vec<u8>> {
if let Ok(elements) = obj.try_bytes_like(vm, |bytes| bytes.to_vec()) {
return Ok(elements);... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/py_io.rs | crates/vm/src/py_io.rs | use crate::{
PyObject, PyObjectRef, PyResult, VirtualMachine,
builtins::{PyBaseExceptionRef, PyBytes, PyStr},
common::ascii,
};
use alloc::fmt;
use core::ops;
use std::io;
pub trait Write {
type Error;
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> Result<(), Self::Error>;
}
#[repr(transpare... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/signal.rs | crates/vm/src/signal.rs | #![cfg_attr(target_os = "wasi", allow(dead_code))]
use crate::{PyResult, VirtualMachine};
use alloc::fmt;
use core::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc;
pub(crate) const NSIG: usize = 64;
static ANY_TRIGGERED: AtomicBool = AtomicBool::new(false);
// hack to get around const array repeat expressio... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/class.rs | crates/vm/src/class.rs | //! Utilities to define a new Python class
use crate::{
PyPayload,
builtins::{PyBaseObject, PyType, PyTypeRef, descriptor::PyWrapper},
function::PyMethodDef,
object::Py,
types::{PyTypeFlags, PyTypeSlots, SLOT_DEFS, hash_not_implemented},
vm::Context,
};
use rustpython_common::static_cell;
/// ... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
RustPython/RustPython | https://github.com/RustPython/RustPython/blob/e1b22f19e62d47485bdb55c9f3a4698221374f5b/crates/vm/src/recursion.rs | crates/vm/src/recursion.rs | use crate::{AsObject, PyObject, VirtualMachine};
pub struct ReprGuard<'vm> {
vm: &'vm VirtualMachine,
id: usize,
}
/// A guard to protect repr methods from recursion into itself,
impl<'vm> ReprGuard<'vm> {
/// Returns None if the guard against 'obj' is still held otherwise returns the guard. The guard
... | rust | MIT | e1b22f19e62d47485bdb55c9f3a4698221374f5b | 2026-01-04T15:39:39.834879Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.