Skip to content

Commit 24d9956

Browse files
coolreader18youknowone
authored andcommitted
Remove some unncessary dependencies
1 parent 696dcea commit 24d9956

File tree

15 files changed

+49
-62
lines changed

15 files changed

+49
-62
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ chrono = "0.4.39"
158158
criterion = { version = "0.3.5", features = ["html_reports"] }
159159
crossbeam-utils = "0.8.21"
160160
flame = "0.2.2"
161-
getrandom = "0.3"
161+
getrandom = { version = "0.3", features = ["std"] }
162162
glob = "0.3"
163163
hex = "0.4.3"
164164
indexmap = { version = "2.2.6", features = ["std"] }
@@ -185,6 +185,7 @@ paste = "1.0.15"
185185
proc-macro2 = "1.0.93"
186186
quote = "1.0.38"
187187
rand = "0.9"
188+
rand_core = { version = "0.9", features = ["os_rng"] }
188189
rustix = { version = "0.38", features = ["event"] }
189190
rustyline = "15.0.0"
190191
serde = { version = "1.0.133", default-features = false }

common/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ascii = { workspace = true }
1919
bitflags = { workspace = true }
2020
bstr = { workspace = true }
2121
cfg-if = { workspace = true }
22+
getrandom = { workspace = true }
2223
itertools = { workspace = true }
2324
libc = { workspace = true }
2425
malachite-bigint = { workspace = true }
@@ -28,12 +29,11 @@ memchr = { workspace = true }
2829
num-traits = { workspace = true }
2930
once_cell = { workspace = true }
3031
parking_lot = { workspace = true, optional = true }
31-
rand = { workspace = true }
3232
unicode_names2 = { workspace = true }
3333

3434
lock_api = "0.4"
3535
radium = "0.7"
36-
siphasher = "0.3"
36+
siphasher = "1"
3737
volatile = "0.3"
3838

3939
[target.'cfg(windows)'.dependencies]

common/src/hash.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@ impl BuildHasher for HashSecret {
3737
}
3838
}
3939

40-
impl rand::distr::Distribution<HashSecret> for rand::distr::StandardUniform {
41-
fn sample<R: rand::Rng + ?Sized>(&self, rng: &mut R) -> HashSecret {
42-
HashSecret {
43-
k0: rng.random(),
44-
k1: rng.random(),
45-
}
46-
}
47-
}
48-
4940
impl HashSecret {
5041
pub fn new(seed: u32) -> Self {
5142
let mut buf = [0u8; 16];

common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub mod int;
2323
pub mod linked_list;
2424
pub mod lock;
2525
pub mod os;
26+
pub mod rand;
2627
pub mod rc;
2728
pub mod refcount;
2829
pub mod static_cell;

common/src/rand.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// Get `N` bytes of random data.
2+
///
3+
/// This function is mildly expensive to call, as it fetches random data
4+
/// directly from the OS entropy source.
5+
///
6+
/// # Panics
7+
///
8+
/// Panics if the OS entropy source returns an error.
9+
pub fn os_random<const N: usize>() -> [u8; N] {
10+
let mut buf = [0u8; N];
11+
getrandom::fill(&mut buf).unwrap();
12+
buf
13+
}

compiler/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ ruff_source_file = { workspace = true }
1919
ruff_text_size = { workspace = true }
2020
thiserror = { workspace = true }
2121

22+
[dev-dependencies]
23+
rand = { workspace = true }
24+
2225
[lints]
2326
workspace = true

stdlib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ puruspe = "0.4.0"
5050
xml-rs = "0.8.14"
5151

5252
# random
53-
rand = { workspace = true }
53+
rand_core = { workspace = true }
5454
mt19937 = "3.1"
5555

5656
# Crypto:

stdlib/src/random.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mod _random {
1616
use malachite_bigint::{BigInt, BigUint, Sign};
1717
use mt19937::MT19937;
1818
use num_traits::{Signed, Zero};
19-
use rand::{RngCore, SeedableRng};
19+
use rand_core::{RngCore, SeedableRng};
2020
use rustpython_vm::types::DefaultConstructor;
2121

2222
#[pyattr]

stdlib/src/uuid.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ mod _uuid {
1010
fn get_node_id() -> [u8; 6] {
1111
match get_mac_address() {
1212
Ok(Some(_ma)) => get_mac_address().unwrap().unwrap().bytes(),
13-
_ => rand::random::<[u8; 6]>(),
13+
// os_random is expensive, but this is only ever called once
14+
_ => rustpython_common::rand::os_random::<6>(),
1415
}
1516
}
1617

0 commit comments

Comments
 (0)