1#![cfg_attr(docsrs, feature(doc_auto_cfg))]
2#![cfg_attr(feature = "simd", feature(portable_simd))]
3#![allow(ambiguous_glob_reexports)]
4#![cfg_attr(
5 feature = "allow_unused",
6 allow(unused, dead_code, irrefutable_let_patterns)
7)] #![cfg_attr(feature = "nightly", allow(clippy::non_canonical_partial_ord_impl))] extern crate core;
11
12#[macro_use]
13pub mod utils;
14pub mod chunked_array;
15pub mod config;
16pub mod datatypes;
17pub mod error;
18pub mod fmt;
19pub mod frame;
20pub mod functions;
21pub mod hashing;
22mod named_from;
23pub mod prelude;
24#[cfg(feature = "random")]
25pub mod random;
26pub mod scalar;
27pub mod schema;
28#[cfg(feature = "serde")]
29pub mod serde;
30pub mod series;
31pub mod testing;
32#[cfg(test)]
33mod tests;
34
35use std::sync::{LazyLock, Mutex};
36use std::time::{SystemTime, UNIX_EPOCH};
37
38pub use datatypes::SchemaExtPl;
39pub use hashing::IdBuildHasher;
40use rayon::{ThreadPool, ThreadPoolBuilder};
41
42pub static PROCESS_ID: LazyLock<u128> = LazyLock::new(|| {
43 SystemTime::now()
44 .duration_since(UNIX_EPOCH)
45 .unwrap()
46 .as_nanos()
47});
48
49#[cfg(not(target_family = "wasm"))] pub static POOL: LazyLock<ThreadPool> = LazyLock::new(|| {
52 let thread_name = std::env::var("POLARS_THREAD_NAME").unwrap_or_else(|_| "polars".to_string());
53 ThreadPoolBuilder::new()
54 .num_threads(
55 std::env::var("POLARS_MAX_THREADS")
56 .map(|s| s.parse::<usize>().expect("integer"))
57 .unwrap_or_else(|_| {
58 std::thread::available_parallelism()
59 .unwrap_or(std::num::NonZeroUsize::new(1).unwrap())
60 .get()
61 }),
62 )
63 .thread_name(move |i| format!("{thread_name}-{i}"))
64 .build()
65 .expect("could not spawn threads")
66});
67
68#[cfg(all(target_os = "emscripten", target_family = "wasm"))] pub static POOL: LazyLock<ThreadPool> = LazyLock::new(|| {
70 ThreadPoolBuilder::new()
71 .num_threads(1)
72 .use_current_thread()
73 .build()
74 .expect("could not create pool")
75});
76
77#[cfg(all(not(target_os = "emscripten"), target_family = "wasm"))] pub static POOL: LazyLock<polars_utils::wasm::Pool> = LazyLock::new(|| polars_utils::wasm::Pool);
79
80pub static SINGLE_LOCK: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(()));
82
83pub(crate) const HEAD_DEFAULT_LENGTH: usize = 10;
85pub(crate) const TAIL_DEFAULT_LENGTH: usize = 10;
87pub const CHEAP_SERIES_HASH_LIMIT: usize = 1000;