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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2
Original file line number
Diff line number
Diff line change
@@ -24,11 +24,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
24
24
- The `GILGuard` returned from `Python::acquire_gil` will now only assume responsiblity for freeing owned references on drop if no other `GILPool` or `GILGuard` exists. This ensures that multiple calls to the safe api `Python::acquire_gil` cannot lead to dangling references. [#893](https://github.com/PyO3/pyo3/pull/893)
25
25
- The trait `ObjectProtocol` has been removed, and all the methods from the trait have been moved to `PyAny`. [#911](https://github.com/PyO3/pyo3/pull/911)
26
26
- The exception to this is `ObjectProtocol::None`, which has simply been removed. Use `Python::None` instead.
27
+
- No `#![feature(specialization)]` in user code. [#917](https://github.com/PyO3/pyo3/pull/917)
27
28
28
29
### Removed
29
30
-`PyMethodsProtocol` is now renamed to `PyMethodsImpl` and hidden. [#889](https://github.com/PyO3/pyo3/pull/889)
30
31
-`num-traits` is no longer a dependency. [#895](https://github.com/PyO3/pyo3/pull/895)
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,77 @@ 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