Skip to content

enumerate.__length_hint__ #151387

@casperdcl

Description

@casperdcl

Feature or enhancement

Proposal:

It would be nice if enumerate could expose the underlying len(iterable).

assert len(range(9)) == len(enumerate(range(9)))

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

As per tqdm#1185, there are 200k+ scripts using tqdm(enumerate(...)) on GitHub which would benefit from transparent len().

Somewhat related: #145361 and tqdm.contrib.itertools

/CC @KowalskiThomas @cmaloney @rhettinger

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions