polars-core 0.53.0

Core of the Polars DataFrame library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::sync::{LazyLock, Mutex};

use rand::prelude::*;

static POLARS_GLOBAL_RNG_STATE: LazyLock<Mutex<SmallRng>> =
    LazyLock::new(|| Mutex::new(SmallRng::from_os_rng()));

pub(crate) fn get_global_random_u64() -> u64 {
    POLARS_GLOBAL_RNG_STATE.lock().unwrap().next_u64()
}

pub fn set_global_random_seed(seed: u64) {
    *POLARS_GLOBAL_RNG_STATE.lock().unwrap() = SmallRng::seed_from_u64(seed);
}