Path: blob/main/crates/polars-python/src/lazyframe/mod.rs
7889 views
mod exitable;1#[cfg(feature = "pymethods")]2mod general;3mod optflags;4#[cfg(feature = "pymethods")]5mod serde;6mod sink;7pub mod visit;8pub mod visitor;910#[cfg(not(target_arch = "wasm32"))]11pub use exitable::PyInProcessQuery;12use parking_lot::RwLock;13use polars::prelude::{Engine, LazyFrame, OptFlags};14use pyo3::exceptions::PyValueError;15use pyo3::pybacked::PyBackedStr;16use pyo3::types::PyAnyMethods;17use pyo3::{Bound, FromPyObject, PyAny, PyResult, pyclass};1819use crate::prelude::Wrap;2021#[pyclass(frozen)]22#[repr(transparent)]23pub struct PyLazyFrame {24pub ldf: RwLock<LazyFrame>,25}2627impl Clone for PyLazyFrame {28fn clone(&self) -> Self {29Self {30ldf: RwLock::new(self.ldf.read().clone()),31}32}33}3435impl From<LazyFrame> for PyLazyFrame {36fn from(ldf: LazyFrame) -> Self {37PyLazyFrame {38ldf: RwLock::new(ldf),39}40}41}4243impl From<PyLazyFrame> for LazyFrame {44fn from(pldf: PyLazyFrame) -> Self {45pldf.ldf.into_inner()46}47}4849#[pyclass(frozen)]50#[repr(transparent)]51pub struct PyOptFlags {52pub inner: RwLock<OptFlags>,53}5455impl Clone for PyOptFlags {56fn clone(&self) -> Self {57Self {58inner: RwLock::new(*self.inner.read()),59}60}61}6263impl From<OptFlags> for PyOptFlags {64fn from(inner: OptFlags) -> Self {65PyOptFlags {66inner: RwLock::new(inner),67}68}69}7071impl<'py> FromPyObject<'py> for Wrap<Engine> {72fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {73let parsed = ob74.extract::<PyBackedStr>()?75.parse()76.map_err(PyValueError::new_err)?;77Ok(Wrap(parsed))78}79}808182