From b2fe4b568b6a5eb2503de7eaf6d0a3b5ca57e329 Mon Sep 17 00:00:00 2001 From: Padraic Fanning <27117322+fanninpm@users.noreply.github.com> Date: Fri, 22 May 2026 21:48:30 -0400 Subject: [PATCH 1/5] Add `rapidhash` to list of dependencies --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 567e68a91dd..e2746f14571 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -260,6 +260,7 @@ quote = "1.0.45" radium = "1.1.1" rand = "0.9" rand_core = { version = "0.9", features = ["os_rng"] } +rapidhash = "4.4.1" result-like = "0.5.0" rustix = { version = "1.1", features = ["event", "param", "system"] } rustls = { version = "0.23.39", default-features = false } From 3b71c63e591d3a9e6b94a74f788bdcc49be9fe67 Mon Sep 17 00:00:00 2001 From: Padraic Fanning <27117322+fanninpm@users.noreply.github.com> Date: Fri, 22 May 2026 21:57:23 -0400 Subject: [PATCH 2/5] Use `rapidhash::quality::RandomState` in `codegen` crate --- Cargo.lock | 11 ++++++++++- crates/codegen/Cargo.toml | 2 +- crates/codegen/src/lib.rs | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eab7707b5be..eaeb44c54e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2928,6 +2928,15 @@ dependencies = [ "getrandom 0.3.4", ] +[[package]] +name = "rapidhash" +version = "4.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e48930979c155e2f33aa36ab3119b5ee81332beb6482199a8ecd6029b80b59" +dependencies = [ + "rustversion", +] + [[package]] name = "rayon" version = "1.12.0" @@ -3241,7 +3250,6 @@ dependencies = [ name = "rustpython-codegen" version = "0.5.0" dependencies = [ - "ahash", "bitflags 2.11.1", "indexmap", "itertools 0.14.0", @@ -3250,6 +3258,7 @@ dependencies = [ "memchr", "num-complex", "num-traits", + "rapidhash", "rustpython-compiler-core", "rustpython-literal", "rustpython-ruff_python_ast", diff --git a/crates/codegen/Cargo.toml b/crates/codegen/Cargo.toml index 4f32fcc3c3f..031f3b96521 100644 --- a/crates/codegen/Cargo.toml +++ b/crates/codegen/Cargo.toml @@ -19,7 +19,6 @@ rustpython-wtf8 = { workspace = true } ruff_python_ast = { workspace = true } ruff_text_size = { workspace = true } -ahash = { workspace = true } bitflags = { workspace = true } indexmap = { workspace = true } itertools = { workspace = true } @@ -29,6 +28,7 @@ num-traits = { workspace = true } thiserror = { workspace = true } malachite-bigint = { workspace = true } memchr = { workspace = true } +rapidhash = { workspace = true } unicode_names2 = { workspace = true } [dev-dependencies] diff --git a/crates/codegen/src/lib.rs b/crates/codegen/src/lib.rs index 8d6ad984354..b598ab7e933 100644 --- a/crates/codegen/src/lib.rs +++ b/crates/codegen/src/lib.rs @@ -8,8 +8,8 @@ extern crate log; extern crate alloc; -type IndexMap = indexmap::IndexMap; -type IndexSet = indexmap::IndexSet; +type IndexMap = indexmap::IndexMap; +type IndexSet = indexmap::IndexSet; pub mod compile; pub mod error; From 3c484f4b4c6669effbd42974e2ae1fc89c4c2ef1 Mon Sep 17 00:00:00 2001 From: Padraic Fanning <27117322+fanninpm@users.noreply.github.com> Date: Sat, 23 May 2026 20:00:29 -0400 Subject: [PATCH 3/5] Use `rapidhash::quality::RandomState` in `stdlib` crate --- Cargo.lock | 2 +- crates/stdlib/Cargo.toml | 2 +- crates/stdlib/src/contextvars.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eaeb44c54e8..7091b918abf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3507,7 +3507,6 @@ name = "rustpython-stdlib" version = "0.5.0" dependencies = [ "adler32", - "ahash", "ascii", "aws-lc-rs", "base64", @@ -3558,6 +3557,7 @@ dependencies = [ "pkcs8", "pymath", "rand_core 0.9.5", + "rapidhash", "rustls", "rustls-native-certs", "rustls-pemfile", diff --git a/crates/stdlib/Cargo.toml b/crates/stdlib/Cargo.toml index f77d467d63e..88afc243274 100644 --- a/crates/stdlib/Cargo.toml +++ b/crates/stdlib/Cargo.toml @@ -37,7 +37,6 @@ ruff_python_ast = { workspace = true } ruff_text_size = { workspace = true } ruff_source_file = { workspace = true } -ahash = { workspace = true } ascii = { workspace = true } crossbeam-utils = { workspace = true } flame = { workspace = true, optional = true } @@ -51,6 +50,7 @@ num-traits = { workspace = true } num_enum = { workspace = true } parking_lot = { workspace = true } phf = { workspace = true, default-features = true, features = ["macros"] } +rapidhash = { workspace = true } memchr = { workspace = true } base64 = { workspace = true } diff --git a/crates/stdlib/src/contextvars.rs b/crates/stdlib/src/contextvars.rs index ee5942755c1..0a6e0f12314 100644 --- a/crates/stdlib/src/contextvars.rs +++ b/crates/stdlib/src/contextvars.rs @@ -28,7 +28,7 @@ mod _contextvars { use indexmap::IndexMap; // TODO: Real hamt implementation - type Hamt = IndexMap, PyObjectRef, ahash::RandomState>; + type Hamt = IndexMap, PyObjectRef, rapidhash::quality::RandomState>; #[pyclass(no_attr, name = "Hamt", module = "contextvars")] #[derive(Debug, PyPayload)] From c95d58198f71b628b4991749603604f912b2356f Mon Sep 17 00:00:00 2001 From: Padraic Fanning <27117322+fanninpm@users.noreply.github.com> Date: Sat, 23 May 2026 20:33:17 -0400 Subject: [PATCH 4/5] Use `rapidhash::quality::RandomState` in `vm` crate --- Cargo.lock | 15 +-------------- crates/vm/Cargo.toml | 2 +- crates/vm/src/builtins/type.rs | 3 ++- crates/vm/src/intern.rs | 2 +- crates/vm/src/vm/interpreter.rs | 7 +++++-- crates/vm/src/vm/mod.rs | 2 +- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7091b918abf..0d191fc99ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,19 +25,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "ahash" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" -dependencies = [ - "cfg-if", - "getrandom 0.3.4", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.4" @@ -3597,7 +3584,6 @@ version = "0.5.0" name = "rustpython-vm" version = "0.5.0" dependencies = [ - "ahash", "ascii", "bitflags 2.11.1", "bstr", @@ -3628,6 +3614,7 @@ dependencies = [ "parking_lot", "paste", "psm", + "rapidhash", "result-like", "rustpython-codegen", "rustpython-common", diff --git a/crates/vm/Cargo.toml b/crates/vm/Cargo.toml index 8ff078b818f..83e41fa1f5f 100644 --- a/crates/vm/Cargo.toml +++ b/crates/vm/Cargo.toml @@ -44,7 +44,6 @@ rustpython-literal = { workspace = true } rustpython-sre_engine = { workspace = true } ascii = { workspace = true } -ahash = { workspace = true } bitflags = { workspace = true } bstr = { workspace = true } crossbeam-utils = { workspace = true } @@ -64,6 +63,7 @@ num-traits = { workspace = true } num_enum = { workspace = true } parking_lot = { workspace = true } paste = { workspace = true } +rapidhash = { workspace = true } scopeguard = { workspace = true } serde = { workspace = true, optional = true } static_assertions = { workspace = true } diff --git a/crates/vm/src/builtins/type.rs b/crates/vm/src/builtins/type.rs index 8b920c2fee1..fa673d42034 100644 --- a/crates/vm/src/builtins/type.rs +++ b/crates/vm/src/builtins/type.rs @@ -408,7 +408,8 @@ cfg_select! { /// For attributes we do not use a dict, but an IndexMap, which is an Hash Table /// that maintains order and is compatible with the standard HashMap This is probably /// faster and only supports strings as keys. -pub(crate) type PyAttributes = IndexMap<&'static PyStrInterned, PyObjectRef, ahash::RandomState>; +pub(crate) type PyAttributes = + IndexMap<&'static PyStrInterned, PyObjectRef, rapidhash::quality::RandomState>; unsafe impl Traverse for PyAttributes { fn traverse(&self, tracer_fn: &mut TraverseFn<'_>) { diff --git a/crates/vm/src/intern.rs b/crates/vm/src/intern.rs index da1d63f8791..981732f2dd2 100644 --- a/crates/vm/src/intern.rs +++ b/crates/vm/src/intern.rs @@ -11,7 +11,7 @@ use core::{borrow::Borrow, ops::Deref}; #[derive(Debug)] pub(crate) struct StringPool { - inner: PyRwLock>, + inner: PyRwLock>, } impl Default for StringPool { diff --git a/crates/vm/src/vm/interpreter.rs b/crates/vm/src/vm/interpreter.rs index 505986acae0..bb0b80bb63b 100644 --- a/crates/vm/src/vm/interpreter.rs +++ b/crates/vm/src/vm/interpreter.rs @@ -95,8 +95,11 @@ where } as usize); // Initialize frozen modules (core + user-provided) - let mut frozen: std::collections::HashMap<&'static str, FrozenModule, ahash::RandomState> = - core_frozen_inits().collect(); + let mut frozen: std::collections::HashMap< + &'static str, + FrozenModule, + rapidhash::quality::RandomState, + > = core_frozen_inits().collect(); frozen.extend(frozen_modules); // Create PyGlobalState diff --git a/crates/vm/src/vm/mod.rs b/crates/vm/src/vm/mod.rs index a99012cd14b..ca89e918575 100644 --- a/crates/vm/src/vm/mod.rs +++ b/crates/vm/src/vm/mod.rs @@ -589,7 +589,7 @@ pub(crate) struct CallableCache { pub struct PyGlobalState { pub config: PyConfig, pub module_defs: BTreeMap<&'static str, &'static builtins::PyModuleDef>, - pub frozen: HashMap<&'static str, FrozenModule, ahash::RandomState>, + pub frozen: HashMap<&'static str, FrozenModule, rapidhash::quality::RandomState>, pub stacksize: AtomicCell, pub thread_count: AtomicCell, pub hash_secret: HashSecret, From 133a66c935680e131e4ca24a678d4f1a76e88f49 Mon Sep 17 00:00:00 2001 From: Padraic Fanning <27117322+fanninpm@users.noreply.github.com> Date: Sat, 23 May 2026 20:35:06 -0400 Subject: [PATCH 5/5] Remove `ahash` from lists of dependencies --- .github/dependabot.yml | 1 - Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e3f9ba3b7ab..7533ce36803 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -85,7 +85,6 @@ updates: - "quote-use*" random: patterns: - - "ahash" - "getrandom" - "mt19937" - "rand*" diff --git a/Cargo.toml b/Cargo.toml index e2746f14571..9fbdd9d71e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -176,7 +176,6 @@ ruff_source_file = { package = "rustpython-ruff_source_file", version = "0.15.8" der = { version = "0.8", features = ["alloc", "oid", "pem", "zeroize"] } phf = { version = "0.13.1", default-features = false, features = ["macros"]} adler32 = "1.2.0" -ahash = "0.8.12" approx = "0.5.1" ascii = "1.1" aws-lc-rs = "1.16.3"