@@ -10,7 +10,16 @@ that which is produced directly by `pythonize`.
10
10
This crate converts Rust types which implement the [ Serde] serialization
11
11
traits into Python objects using the [ PyO3] library.
12
12
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 >
14
23
15
24
[ Serde ] : https://github.com/serde-rs/serde
16
25
[ PyO3 ] : https://github.com/PyO3/pyo3
@@ -20,7 +29,7 @@ Pythonize has two public APIs: `pythonize` and `depythonize`.
20
29
``` rust
21
30
use serde :: {Serialize , Deserialize };
22
31
use pyo3 :: Python ;
23
- use pythonize :: {depythonize , pythonize};
32
+ use pythonize :: {depythonize_bound , pythonize};
24
33
25
34
#[derive(Debug , Serialize , Deserialize , PartialEq )]
26
35
struct Sample {
@@ -37,12 +46,12 @@ let sample = Sample {
37
46
};
38
47
39
48
// Rust -> Python
40
- let obj = pythonize (py , & sample ). unwrap ();
49
+ let obj = pythonize (py , & sample ). unwrap ();
41
50
42
51
assert_eq! (" {'foo': 'Foo', 'bar': None}" , & format! (" {}" , obj . as_ref (py ). repr (). unwrap ()));
43
52
44
53
// 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 ();
46
55
47
56
assert_eq! (new_sample , sample );
48
57
```
0 commit comments