Skip to content

Clean-up tail(). Prefer try/except over the Sized ABC.#1068

Merged
bbayles merged 1 commit intomore-itertools:masterfrom
rhettinger:cleanup_tail
Sep 1, 2025
Merged

Clean-up tail(). Prefer try/except over the Sized ABC.#1068
bbayles merged 1 commit intomore-itertools:masterfrom
rhettinger:cleanup_tail

Conversation

@rhettinger
Copy link
Copy Markdown
Contributor

The best way to determine whether a len call will succeed is to actually call it. This is cheaper. Also it is more reliable. Instead of just testing for the presence of __len__, it verifies that the call actually succeeds and returns a non-negative integer.

@bbayles bbayles merged commit a80f1c5 into more-itertools:master Sep 1, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants