Skip to content

Commit 5dada38

Browse files
committed
add newsfragment and migration
1 parent c3f0e19 commit 5dada38

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

guide/src/migration.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,37 @@ However, take care to note that the behaviour is different from previous version
4747
Related to this, we also added a `pyo3_disable_reference_pool` conditional compilation flag which removes the infrastructure necessary to apply delayed reference count decrements implied by `impl<T> Drop for Py<T>`. They do not appear to be a soundness hazard as they should lead to memory leaks in the worst case. However, the global synchronization adds significant overhead to cross the Python-Rust boundary. Enabling this feature will remove these costs and make the `Drop` implementation abort the process if called without the GIL being held instead.
4848
</details>
4949

50+
### Deprecation of implicit integer comparison for simple enums
51+
<details open>
52+
<summary><small>Click to expand</small></summary>
53+
54+
With `pyo3` 0.22 the implicit implementation of integer comparison for simple enums using their discriminants is deprecated. To migrate, place a `#[pyo3(eq_int)]` attribute on affected classes. In addition the `#[pyo3(eq)]` option can be used to implement comparison based on the `PartialEq` implementation. If both options are specified, comparing by `PartialEq` and on failure the integer comparision is used as a fallback.
55+
56+
Before:
57+
58+
```rust
59+
# #![allow(deprecated, dead_code)]
60+
# use pyo3::prelude::*;
61+
#[pyclass]
62+
enum SimpleEnum {
63+
VariantA,
64+
VariantB = 42,
65+
}
66+
```
67+
68+
After:
69+
70+
```rust
71+
# #![allow(dead_code)]
72+
# use pyo3::prelude::*;
73+
#[pyclass(eq_int)]
74+
enum SimpleEnum {
75+
VariantA,
76+
VariantB = 42,
77+
}
78+
```
79+
</details>
80+
5081
## from 0.20.* to 0.21
5182
<details open>
5283
<summary><small>Click to expand</small></summary>

newsfragments/4210.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `#[pyclass(eq)]` option to generate `__eq__` based on `PartialEq`.

newsfragments/4210.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate implicit integer comparision for simple enums in favor of `#[pyclass(eq_int)]`.

0 commit comments

Comments
 (0)