You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you curious what `#[pyclass]` generates, see [How methods are implemented](#how-methods-are-implemented) section.
90
21
91
22
## Adding the class to a module
92
23
@@ -944,7 +875,93 @@ pyclass dependent on whether there is an impl block, we'd need to implement the
944
875
`#[pyclass]` and override the implementation in `#[pymethods]`, which is to the best of my knowledge
945
876
only possible with the specialization feature, which can't be used on stable.
946
877
947
-
To escape this we use [inventory](https://github.com/dtolnay/inventory), which allows us to collect `impl`s from arbitrary source code by exploiting some binary trick. See [inventory: how it works](https://github.com/dtolnay/inventory#how-it-works) and `pyo3_derive_backend::py_class::impl_inventory` for more details.
878
+
To escape this we use [inventory](https://github.com/dtolnay/inventory),
879
+
which allows us to collect `impl`s from arbitrary source code by exploiting some binary trick.
880
+
See [inventory: how it works](https://github.com/dtolnay/inventory#how-it-works) and `pyo3_derive_backend::py_class` for more details.
881
+
882
+
Specifically, the following implementation is generated:
883
+
884
+
```rust
885
+
usepyo3::prelude::*;
886
+
887
+
/// Class for demonstration
888
+
structMyClass {
889
+
num:i32,
890
+
debug:bool,
891
+
}
892
+
893
+
implpyo3::pyclass::PyClassAllocforMyClass {}
894
+
895
+
unsafeimplpyo3::PyTypeInfoforMyClass {
896
+
typeType=MyClass;
897
+
typeBaseType=PyAny;
898
+
typeBaseLayout=pyo3::pycell::PyCellBase<PyAny>;
899
+
typeLayout=PyCell<Self>;
900
+
typeInitializer=PyClassInitializer<Self>;
901
+
typeAsRefTarget=PyCell<Self>;
902
+
903
+
constNAME:&'staticstr="MyClass";
904
+
constMODULE:Option<&'staticstr> =None;
905
+
constDESCRIPTION:&'staticstr="Class for demonstration";
0 commit comments