Skip to content

Commit bc3d00e

Browse files
authored
Replace ahash with rapidhash (RustPython#7954)
* Add `rapidhash` to list of dependencies * Use `rapidhash::quality::RandomState` in `codegen` crate * Use `rapidhash::quality::RandomState` in `stdlib` crate * Use `rapidhash::quality::RandomState` in `vm` crate * Remove `ahash` from lists of dependencies
1 parent 52305c0 commit bc3d00e

12 files changed

Lines changed: 28 additions & 29 deletions

File tree

.github/dependabot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ updates:
8585
- "quote-use*"
8686
random:
8787
patterns:
88-
- "ahash"
8988
- "getrandom"
9089
- "mt19937"
9190
- "rand*"

Cargo.lock

Lines changed: 12 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ ruff_source_file = { package = "rustpython-ruff_source_file", version = "0.15.8"
176176
der = { version = "0.8", features = ["alloc", "oid", "pem", "zeroize"] }
177177
phf = { version = "0.13.1", default-features = false, features = ["macros"]}
178178
adler32 = "1.2.0"
179-
ahash = "0.8.12"
180179
approx = "0.5.1"
181180
ascii = "1.1"
182181
aws-lc-rs = "1.16.3"
@@ -260,6 +259,7 @@ quote = "1.0.45"
260259
radium = "1.1.1"
261260
rand = "0.9"
262261
rand_core = { version = "0.9", features = ["os_rng"] }
262+
rapidhash = "4.4.1"
263263
result-like = "0.5.0"
264264
rustix = { version = "1.1", features = ["event", "param", "system"] }
265265
rustls = { version = "0.23.39", default-features = false }

crates/codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ rustpython-wtf8 = { workspace = true }
1919
ruff_python_ast = { workspace = true }
2020
ruff_text_size = { workspace = true }
2121

22-
ahash = { workspace = true }
2322
bitflags = { workspace = true }
2423
indexmap = { workspace = true }
2524
itertools = { workspace = true }
@@ -29,6 +28,7 @@ num-traits = { workspace = true }
2928
thiserror = { workspace = true }
3029
malachite-bigint = { workspace = true }
3130
memchr = { workspace = true }
31+
rapidhash = { workspace = true }
3232
unicode_names2 = { workspace = true }
3333

3434
[dev-dependencies]

crates/codegen/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ extern crate log;
88

99
extern crate alloc;
1010

11-
type IndexMap<K, V> = indexmap::IndexMap<K, V, ahash::RandomState>;
12-
type IndexSet<T> = indexmap::IndexSet<T, ahash::RandomState>;
11+
type IndexMap<K, V> = indexmap::IndexMap<K, V, rapidhash::quality::RandomState>;
12+
type IndexSet<T> = indexmap::IndexSet<T, rapidhash::quality::RandomState>;
1313

1414
pub mod compile;
1515
pub mod error;

crates/stdlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ ruff_python_ast = { workspace = true }
3737
ruff_text_size = { workspace = true }
3838
ruff_source_file = { workspace = true }
3939

40-
ahash = { workspace = true }
4140
ascii = { workspace = true }
4241
crossbeam-utils = { workspace = true }
4342
flame = { workspace = true, optional = true }
@@ -51,6 +50,7 @@ num-traits = { workspace = true }
5150
num_enum = { workspace = true }
5251
parking_lot = { workspace = true }
5352
phf = { workspace = true, default-features = true, features = ["macros"] }
53+
rapidhash = { workspace = true }
5454

5555
memchr = { workspace = true }
5656
base64 = { workspace = true }

crates/stdlib/src/contextvars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mod _contextvars {
2828
use indexmap::IndexMap;
2929

3030
// TODO: Real hamt implementation
31-
type Hamt = IndexMap<PyRef<ContextVar>, PyObjectRef, ahash::RandomState>;
31+
type Hamt = IndexMap<PyRef<ContextVar>, PyObjectRef, rapidhash::quality::RandomState>;
3232

3333
#[pyclass(no_attr, name = "Hamt", module = "contextvars")]
3434
#[derive(Debug, PyPayload)]

crates/vm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ rustpython-literal = { workspace = true }
4444
rustpython-sre_engine = { workspace = true }
4545

4646
ascii = { workspace = true }
47-
ahash = { workspace = true }
4847
bitflags = { workspace = true }
4948
bstr = { workspace = true }
5049
crossbeam-utils = { workspace = true }
@@ -64,6 +63,7 @@ num-traits = { workspace = true }
6463
num_enum = { workspace = true }
6564
parking_lot = { workspace = true }
6665
paste = { workspace = true }
66+
rapidhash = { workspace = true }
6767
scopeguard = { workspace = true }
6868
serde = { workspace = true, optional = true }
6969
static_assertions = { workspace = true }

crates/vm/src/builtins/type.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ cfg_select! {
408408
/// For attributes we do not use a dict, but an IndexMap, which is an Hash Table
409409
/// that maintains order and is compatible with the standard HashMap This is probably
410410
/// faster and only supports strings as keys.
411-
pub(crate) type PyAttributes = IndexMap<&'static PyStrInterned, PyObjectRef, ahash::RandomState>;
411+
pub(crate) type PyAttributes =
412+
IndexMap<&'static PyStrInterned, PyObjectRef, rapidhash::quality::RandomState>;
412413

413414
unsafe impl Traverse for PyAttributes {
414415
fn traverse(&self, tracer_fn: &mut TraverseFn<'_>) {

crates/vm/src/intern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use core::{borrow::Borrow, ops::Deref};
1111

1212
#[derive(Debug)]
1313
pub(crate) struct StringPool {
14-
inner: PyRwLock<std::collections::HashSet<CachedPyStrRef, ahash::RandomState>>,
14+
inner: PyRwLock<std::collections::HashSet<CachedPyStrRef, rapidhash::quality::RandomState>>,
1515
}
1616

1717
impl Default for StringPool {

0 commit comments

Comments
 (0)