Skip to content

Commit

Permalink
guide: note __hash__ can have any integer type up to 64 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Aug 23, 2022
1 parent c5ecf47 commit 86a1116
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion guide/src/class/protocols.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ given signatures should be interpreted as follows:

- `__hash__(<self>) -> isize`

Objects that compare equal must have the same hash value.
Objects that compare equal must have the same hash value. Any type up to 64 bits may be returned instead of `isize`, PyO3 will convert to an isize automatically (wrapping unsigned types like `u64` and `usize`).
<details>
<summary>Disabling Python's default hash</summary>
By default, all `#[pyclass]` types have a default hash implementation from Python. Types which should not be hashable can override this by setting `__hash__` to `None`. This is the same mechanism as for a pure-Python class. This is done like so:
Expand Down

0 comments on commit 86a1116

Please sign in to comment.