Skip to content

Dutcho/more-more-itertools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro

Though more-itertools contains many functions, it can never be 'complete'.

Below extensions were or could be proposed, but not (yet) added to more-itertools. Module more-more-itertools acts as their abode until they get added to more-itertools.

Functions

Logic

lazy_product

Lazely iterate over product of *iterables (potentially with repeat), which can be unbounded, differentiating lazy_product from stdlib itertool.product.

  • Still #TODO

diagonal_lazy_product

Lazely iterate over product of *iterables (potentially with repeat), which can be unbounded, in a 'diagonal' fashion.

  • Still #TODO

Count

at_least_n

at_least_n(iterable, /, n, *, too_short=None)

Iterate over iterable and validate it has at least n items.

If it has fewer than n items, call function too_short with its item-count.

  • Suggested for addition to more-itertools as #1053 on 9 Aug 2025.

at_most_n

at_most_n(iterable, /, n, *, too_long=None)

Iterate over the first ≤n items of iterable and validate it has at most n items (i.e. is exhausted then).

If it has more than n items, call function too_long with the number n + 1. Even if too_long doesn't raise, the remaining items (>n) get skipped.

  • Suggested for addition to more-itertools as #1053 on 9 Aug 2025.

Time

throttle

throttle(iterable, /, *, min_step) or throttle(iterable, /, *, max_rate)

Iterate over iterable at (potentially slowed-down) pace of at least min_step sec per item, or at most max_rate items per sec.

timeout

timeout(iterable, /, max_time, *, exception=TimeoutError)

Iterate over iterable with potential premature stop after a timeout of max_time sec. If iterable takes longer than max_time sec, i.e. a timeout occurs, exception is raised if not None. For a timeout with exception None, iteration stops without exception (cf. itertools.islice(), but after certain duration instead of certain count).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages