@@ -90,13 +90,12 @@ impl PyGuide {
90
90
91
91
fn __reduce__ ( & self ) -> PyResult < ( PyObject , ( Vec < u8 > , ) ) > {
92
92
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" ) ?;
95
94
let binary_data: Vec < u8 > =
96
95
bincode:: encode_to_vec ( self , config:: standard ( ) ) . map_err ( |e| {
97
96
PyErr :: new :: < PyValueError , _ > ( format ! ( "Serialization of Guide failed: {}" , e) )
98
97
} ) ?;
99
- Ok ( ( cls. getattr ( "from_binary" ) ?. to_object ( py ) , ( binary_data, ) ) )
98
+ Ok ( ( cls. getattr ( "from_binary" ) ?. unbind ( ) , ( binary_data, ) ) )
100
99
} )
101
100
}
102
101
@@ -167,13 +166,12 @@ impl PyIndex {
167
166
168
167
fn __reduce__ ( & self ) -> PyResult < ( PyObject , ( Vec < u8 > , ) ) > {
169
168
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" ) ?;
172
170
let binary_data: Vec < u8 > = bincode:: encode_to_vec ( & self . 0 , config:: standard ( ) )
173
171
. map_err ( |e| {
174
172
PyErr :: new :: < PyValueError , _ > ( format ! ( "Serialization of Index failed: {}" , e) )
175
173
} ) ?;
176
- Ok ( ( cls. getattr ( "from_binary" ) ?. to_object ( py ) , ( binary_data, ) ) )
174
+ Ok ( ( cls. getattr ( "from_binary" ) ?. unbind ( ) , ( binary_data, ) ) )
177
175
} )
178
176
}
179
177
@@ -300,16 +298,16 @@ impl PyVocabulary {
300
298
301
299
fn __reduce__ ( & self ) -> PyResult < ( PyObject , ( Vec < u8 > , ) ) > {
302
300
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" ) ?;
305
303
let binary_data: Vec < u8 > =
306
304
bincode:: encode_to_vec ( self , config:: standard ( ) ) . map_err ( |e| {
307
305
PyErr :: new :: < PyValueError , _ > ( format ! (
308
306
"Serialization of Vocabulary failed: {}" ,
309
307
e
310
308
) )
311
309
} ) ?;
312
- Ok ( ( cls. getattr ( "from_binary" ) ?. to_object ( py ) , ( binary_data, ) ) )
310
+ Ok ( ( cls. getattr ( "from_binary" ) ?. unbind ( ) , ( binary_data, ) ) )
313
311
} )
314
312
}
315
313
0 commit comments