Skip to content

Commit

Permalink
Switch away from direct reference APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonspeed committed May 9, 2024
1 parent e390142 commit c3790f8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion py-polars/src/conversion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl<'s> FromPyObject<'s> for Wrap<Row<'s>> {

impl<'py> FromPyObject<'py> for Wrap<Schema> {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
let dict = ob.extract::<&PyDict>()?;
let dict = ob.downcast::<PyDict>()?;

Ok(Wrap(
dict.iter()
Expand Down
6 changes: 3 additions & 3 deletions py-polars/src/lazyframe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use polars::time::*;
use polars_core::prelude::*;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
use pyo3::pybacked::PyBackedStr;
use pyo3::pybacked::{PyBackedBytes, PyBackedStr};
use pyo3::types::{PyBytes, PyDict, PyList};
pub(crate) use visit::PyExprIR;

Expand Down Expand Up @@ -59,9 +59,9 @@ impl PyLazyFrame {

fn __setstate__(&mut self, py: Python, state: PyObject) -> PyResult<()> {
// Used in pickle/pickling
match state.extract::<&PyBytes>(py) {
match state.extract::<PyBackedBytes>(py) {
Ok(s) => {
let lp: DslPlan = ciborium::de::from_reader(s.as_bytes())
let lp: DslPlan = ciborium::de::from_reader(&*s)
.map_err(|e| PyPolarsErr::Other(format!("{}", e)))?;
self.ldf = LazyFrame::from(lp);
Ok(())
Expand Down
6 changes: 4 additions & 2 deletions py-polars/src/series/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,11 @@ impl PySeries {
#[cfg(feature = "ipc_streaming")]
fn __setstate__(&mut self, py: Python, state: PyObject) -> PyResult<()> {
// Used in pickle/pickling
match state.extract::<&PyBytes>(py) {

use pyo3::pybacked::PyBackedBytes;
match state.extract::<PyBackedBytes>(py) {
Ok(s) => {
let c = Cursor::new(s.as_bytes());
let c = Cursor::new(&s);
let reader = IpcStreamReader::new(c);
let mut df = reader.finish().map_err(PyPolarsErr::from)?;

Expand Down

0 comments on commit c3790f8

Please sign in to comment.