Skip to content

Commit

Permalink
fix(python): Release the gil on explain (#21607)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Mar 5, 2025
1 parent 4d2aa57 commit d750a78
Showing 1 changed file with 10 additions and 23 deletions.
33 changes: 10 additions & 23 deletions crates/polars-python/src/lazyframe/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,37 +490,24 @@ impl PyLazyFrame {
Ok(LazyFrame::scan_from_python_function(Either::Left(schema_fn), scan_fn, false).into())
}

fn describe_plan(&self) -> PyResult<String> {
self.ldf
.describe_plan()
.map_err(PyPolarsErr::from)
.map_err(Into::into)
fn describe_plan(&self, py: Python) -> PyResult<String> {
py.enter_polars(|| self.ldf.describe_plan())
}

fn describe_optimized_plan(&self) -> PyResult<String> {
self.ldf
.describe_optimized_plan()
.map_err(PyPolarsErr::from)
.map_err(Into::into)
fn describe_optimized_plan(&self, py: Python) -> PyResult<String> {
py.enter_polars(|| self.ldf.describe_optimized_plan())
}

fn describe_plan_tree(&self) -> PyResult<String> {
self.ldf
.describe_plan_tree()
.map_err(PyPolarsErr::from)
.map_err(Into::into)
fn describe_plan_tree(&self, py: Python) -> PyResult<String> {
py.enter_polars(|| self.ldf.describe_plan_tree())
}

fn describe_optimized_plan_tree(&self) -> PyResult<String> {
self.ldf
.describe_optimized_plan_tree()
.map_err(PyPolarsErr::from)
.map_err(Into::into)
fn describe_optimized_plan_tree(&self, py: Python) -> PyResult<String> {
py.enter_polars(|| self.ldf.describe_optimized_plan_tree())
}

fn to_dot(&self, optimized: bool) -> PyResult<String> {
let result = self.ldf.to_dot(optimized).map_err(PyPolarsErr::from)?;
Ok(result)
fn to_dot(&self, py: Python, optimized: bool) -> PyResult<String> {
py.enter_polars(|| self.ldf.to_dot(optimized))
}

fn optimization_toggle(
Expand Down

0 comments on commit d750a78

Please sign in to comment.