Skip to content

Commit 33d6deb

Browse files
414owentorymur
authored andcommitted
Upgrade pyo3 to 0.23
1 parent 2dfb1dd commit 33d6deb

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ rust-version = "1.71.1"
1010
[dependencies]
1111
once_cell = "1.20"
1212
thiserror = "2.0"
13-
pyo3 = { version = "0.22.0", features = ["extension-module"], optional = true }
13+
pyo3 = { version = "0.23", features = ["extension-module"], optional = true }
1414
regex = "1.10.6"
15-
serde-pyobject = { version = "0.4.0", optional = true }
15+
serde-pyobject = { version = "0.5.0", optional = true }
1616
serde_json = { version = "1.0", features = ["preserve_order"] }
1717
serde = {version = "1.0", features = ["derive"]}
1818
bincode = "2.0.0-rc.3"

src/python_bindings/mod.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,12 @@ impl PyGuide {
9090

9191
fn __reduce__(&self) -> PyResult<(PyObject, (Vec<u8>,))> {
9292
Python::with_gil(|py| {
93-
let cls =
94-
PyModule::import_bound(py, "outlines_core.outlines_core_rs")?.getattr("Guide")?;
93+
let cls = PyModule::import(py, "outlines_core.outlines_core_rs")?.getattr("Guide")?;
9594
let binary_data: Vec<u8> =
9695
bincode::encode_to_vec(self, config::standard()).map_err(|e| {
9796
PyErr::new::<PyValueError, _>(format!("Serialization of Guide failed: {}", e))
9897
})?;
99-
Ok((cls.getattr("from_binary")?.to_object(py), (binary_data,)))
98+
Ok((cls.getattr("from_binary")?.unbind(), (binary_data,)))
10099
})
101100
}
102101

@@ -167,13 +166,12 @@ impl PyIndex {
167166

168167
fn __reduce__(&self) -> PyResult<(PyObject, (Vec<u8>,))> {
169168
Python::with_gil(|py| {
170-
let cls =
171-
PyModule::import_bound(py, "outlines_core.outlines_core_rs")?.getattr("Index")?;
169+
let cls = PyModule::import(py, "outlines_core.outlines_core_rs")?.getattr("Index")?;
172170
let binary_data: Vec<u8> = bincode::encode_to_vec(&self.0, config::standard())
173171
.map_err(|e| {
174172
PyErr::new::<PyValueError, _>(format!("Serialization of Index failed: {}", e))
175173
})?;
176-
Ok((cls.getattr("from_binary")?.to_object(py), (binary_data,)))
174+
Ok((cls.getattr("from_binary")?.unbind(), (binary_data,)))
177175
})
178176
}
179177

@@ -300,16 +298,16 @@ impl PyVocabulary {
300298

301299
fn __reduce__(&self) -> PyResult<(PyObject, (Vec<u8>,))> {
302300
Python::with_gil(|py| {
303-
let cls = PyModule::import_bound(py, "outlines_core.outlines_core_rs")?
304-
.getattr("Vocabulary")?;
301+
let cls =
302+
PyModule::import(py, "outlines_core.outlines_core_rs")?.getattr("Vocabulary")?;
305303
let binary_data: Vec<u8> =
306304
bincode::encode_to_vec(self, config::standard()).map_err(|e| {
307305
PyErr::new::<PyValueError, _>(format!(
308306
"Serialization of Vocabulary failed: {}",
309307
e
310308
))
311309
})?;
312-
Ok((cls.getattr("from_binary")?.to_object(py), (binary_data,)))
310+
Ok((cls.getattr("from_binary")?.unbind(), (binary_data,)))
313311
})
314312
}
315313

0 commit comments

Comments
 (0)