polars_python/
py_modules.rs1use pyo3::prelude::*;
2use pyo3::sync::GILOnceCell;
3
4static POLARS: GILOnceCell<Py<PyModule>> = GILOnceCell::new();
5static UTILS: GILOnceCell<PyObject> = GILOnceCell::new();
6static SERIES: GILOnceCell<PyObject> = GILOnceCell::new();
7
8pub(crate) fn polars(py: Python<'_>) -> &Py<PyModule> {
9 POLARS.get_or_init(py, || py.import("polars").unwrap().unbind())
10}
11
12pub(crate) fn pl_utils(py: Python<'_>) -> &PyObject {
13 UTILS.get_or_init(py, || polars(py).getattr(py, "_utils").unwrap())
14}
15
16pub(crate) fn pl_series(py: Python<'_>) -> &PyObject {
17 SERIES.get_or_init(py, || polars(py).getattr(py, "Series").unwrap())
18}