Nick Coghlan <ncogh...@gmail.com> added the comment:
(I've updated the issue title to state the design requirement, rather than one potential solution to the design requirement) I like the declarative `__infinite_iterator__` suggestion, as that's: 1. really easy to implement when defining a custom iterator type (whether in Python or in an extension module 2. relatively easy to add to generator-iterators as a read-write property that defaults to False (which could then be set to True via an "itertools.infinite_generator" decorator) 3. relatively easy to support in iterators like map, filter, etc via a property that delegates the response to the underlying iterator 4. even more complex iterators like chain, product, and combinations would be able to define a property based on "any(itr.__infinite__iterator__ in underyling_iterators)" ---------- title: Raise OverflowError in __length_hint__ for consistently infinite iterators -> Provide a robust O(1) mechanism to check for infinite iterators _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33939> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com