@@ -44,7 +44,7 @@ references is done at runtime using `PyCell`, a scheme very similar to
44
44
` std::cell::RefCell ` .
45
45
46
46
47
- ## Smart pointers
47
+ ## Object types
48
48
49
49
### ` PyObject `
50
50
@@ -90,23 +90,37 @@ lifetime. Currently, `PyAny` can only ever occur as a reference, e.g. `&PyAny`
90
90
or ` PyRef<PyAny> ` .
91
91
92
92
** Used:** Whenever you want to refer to some Python object only as long as
93
- holding the GIL. For example, arguments to ` pyfunction ` s or ` pymethod ` s
94
- implemented in Rust where any type is allowed.
93
+ holding the GIL. For example, intermediate values and arguments to
94
+ ` pyfunction ` s or ` pymethod ` s implemented in Rust where any type is allowed.
95
95
96
96
** Conversions:**
97
97
98
98
- To ` PyObject ` : ` obj.to_object(py) `
99
99
100
100
101
+ ### ` PyTuple ` , ` PyDict ` , and many more
102
+
103
+ ** Represents:** a native Python object of known type, restricted to a GIL
104
+ lifetime just like ` PyAny ` .
105
+
106
+ ** Used:** Whenever you want to operate with native Python types while holding
107
+ the GIL. Like ` PyAny ` , this is the most convenient form to use for function
108
+ arguments and intermediate values.
109
+
110
+ ** Conversions:**
111
+
112
+ - To ` PyAny ` : ` obj.as_ref() `
113
+
114
+
101
115
### ` PyCell<SomeType> `
102
116
103
- ** Represents:** a reference to a ` PyClass ` instance which is wrapped in a Python
104
- object. The cell part is an analog to stdlib's [ ` RefCell ` ] [ RefCell ] to allow access to
105
- ` &mut ` references.
117
+ ** Represents:** a reference to a Rust object (instance of ` PyClass ` ) which is
118
+ wrapped in a Python object. The cell part is an analog to stdlib's
119
+ [ ` RefCell ` ] [ RefCell ] to allow access to ` &mut ` references.
106
120
107
121
** Used:** for accessing pure-Rust API of the instance (members and functions
108
- taking ` &SomeType ` or ` &mut SomeType ` ) while maintaining the aliasing rules
109
- of Rust references.
122
+ taking ` &SomeType ` or ` &mut SomeType ` ) while maintaining the aliasing rules of
123
+ Rust references.
110
124
111
125
** Conversions:**
112
126
0 commit comments