8000 [3.12] Fix iter_index() to work with lists which do not support stop=None. (gh-109306) by miss-islington · Pull Request #109310 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.12] Fix iter_index() to work with lists which do not support stop=None. (gh-109306) #109310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ which incur interpreter overhead.
yield i
else:
# Fast path for sequences
stop = len(iterable) if stop is None else stop
i = start - 1
try:
while True:
Expand Down Expand Up @@ -1344,6 +1345,16 @@ The following recipes have a more mathematical flavor:
Traceback (most recent call last):
...
ValueError
>>> # Verify that both paths can find identical NaN values
>>> x = float('NaN')
>>> y = float('NaN')
>>> list(iter_index([0, x, x, y, 0], x))
[1, 2]
>>> list(iter_index(iter([0, x, x, y, 0]), x))
[1, 2]
>>> # Test list input. Lists do not support None for the stop argument
>>> list(iter_index(list('AABCADEAF'), 'A'))
[0, 1, 4, 7]

>>> list(sieve(30))
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
Expand Down
0