8000 Itertools recipes improvements · Issue #116842 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Itertools recipes improvements #116842
Closed
Closed
@pochmann3

Description

@pochmann3

roundrobin

>>> ranges = [range(5, 1000), range(4, 3000), range(0), range(3, 2000), range(2, 5000), range(1, 3500)]
>>> collections.Counter(roundrobin(ranges)) == collections.Counter(ranges)

That looks weird. Round-robin with a single iterable? And the ranges aren't iterated? I suspect this was intended:

collections.Counter(roundrobin(*ranges)) == collections.Counter(chain(*ranges))

unique_everseen

These could be lazier by yielding first (before updating seen):

seen.add(element)
yield element

seen.add(k)
yield element

The similar "roughly equivalent" code of cycle and the factor recipe also yield as early as they can.

iter_index

>>> # For example, bytes and str perform subsequence searches

Not really subsequence searches but substring searches. For example, "fbr" is a subsequence of "foobar", but they don't search for that. See Subsequence and Substring at Wikipedia.

@rhettinger

Linked PRs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0