Skip to content

Commit

Permalink
Update guide/src/migration.md
Browse files Browse the repository at this point in the history
Co-authored-by: David Hewitt <[email protected]>
  • Loading branch information
adamreichold and davidhewitt authored Dec 20, 2023
1 parent b786bc2 commit e92db15
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion guide/src/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Python::with_gil(|py| {

### `Iter(A)NextOutput` are deprecated

The `IterNextOutput` used by `__next__` and `IterANextOutput` used by `__anext__` are deprecated. These slots can now return any type convertible into Python objects direclty using the same mechanism as other functions and methods implemented using PyO3. Most importantly, this allows returning an awaitable from `__anext__` without non-sensically wrapping it into `Yield` or `Some`. Only the return types `Option<T>` and `PyResult<Option<T>>` are still handled in special manner where `Some(val)` yields `val` and `None` stops iteration.
The `__next__` and `__anext__` magic methods can now return any type convertible into Python objects directly just like all other `#[pymethods]`. The `IterNextOutput` used by `__next__` and `IterANextOutput` used by `__anext__` are subsequently deprecated. Most importantly, this change allows returning an awaitable from `__anext__` without non-sensically wrapping it into `Yield` or `Some`. Only the return types `Option<T>` and `PyResult<Option<T>>` are still handled in a special manner where `Some(val)` yields `val` and `None` stops iteration.

Starting with an implementation of a Python iterator using `IterNextOutput`, e.g.

Expand Down

0 comments on commit e92db15

Please sign in to comment.