@@ -10,7 +10,16 @@ that which is produced directly by `pythonize`.
1010This crate converts Rust types which implement the [ Serde] serialization
1111traits into Python objects using the [ PyO3] library.
1212
13- Pythonize has two public APIs: ` pythonize ` and ` depythonize ` .
13+ Pythonize has two public APIs: ` pythonize ` and ` depythonize_bound ` .
14+
15+
16+ <div class =" warning " >
17+
18+ ⚠️ Warning: API update in progress 🛠️
19+
20+ PyO3 0.21 has introduced a significant new API, termed the "Bound" API after the new smart pointer ` Bound<T> ` , and pythonize is doing the same.
21+
22+ </div >
1423
1524[ Serde ] : https://github.com/serde-rs/serde
1625[ PyO3 ] : https://github.com/PyO3/pyo3
@@ -20,7 +29,7 @@ Pythonize has two public APIs: `pythonize` and `depythonize`.
2029``` rust
2130use serde :: {Serialize , Deserialize };
2231use pyo3 :: Python ;
23- use pythonize :: {depythonize , pythonize};
32+ use pythonize :: {depythonize_bound , pythonize};
2433
2534#[derive(Debug , Serialize , Deserialize , PartialEq )]
2635struct Sample {
@@ -37,12 +46,12 @@ let sample = Sample {
3746};
3847
3948// Rust -> Python
40- let obj = pythonize (py , & sample ). unwrap ();
49+ let obj = pythonize (py , & sample ). unwrap ();
4150
4251assert_eq! (" {'foo': 'Foo', 'bar': None}" , & format! (" {}" , obj . as_ref (py ). repr (). unwrap ()));
4352
4453// Python -> Rust
45- let new_sample : Sample = depythonize (obj . as_ref (py )). unwrap ();
54+ let new_sample : Sample = depythonize_bound (obj . into_bound (py )). unwrap ();
4655
4756assert_eq! (new_sample , sample );
4857```
0 commit comments