Skip to content

Reported length of zip of stateful iterators wrong #47790

Closed
@jakobnissen

Description

@jakobnissen

A common idiom in the Python world to partition an iterator into chunks of length N is to turn it into a stateful iterator, then zip it with itself N times.

However, such a Zip iterator in Julia falsely report to have the same length as the original iterator.

Perhaps the takeaway is that stateful iterators cannot be HasLength or HasShape, as it's unknowable if another reference to the iterator iterates it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorcorrectness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingiterationInvolves iteration or the iteration protocol

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions