Erik Bray <erik.m.b...@gmail.com> added the comment:

Per the discussion in https://trac.sagemath.org/ticket/24757, it would also be 
nice if some other common iterables like map and filter implemented a similar 
__length_hint__ which would interrogate whatever iterables were give as their 
argument(s).

To summarize the discussion in that ticket, it would be nice to at least know 
if I can expect some iterable to be finite without actually knowing its length. 
 Sure, if I passed in some arbitrary generator there's no way for the 
intepreter to know a priori if it will terminate.  But I would at least like to 
be able to manually mark whether I expect, as an intelligent developer, that 
under normal conditions the generator *should* terminate.  And this information 
should filter up to other iterators that I pass my generator to.  That way I 
can code defensively around whether or not I at least expect an iterator to be 
finite (even if not of a known length).

----------
nosy: +erik.bray

_______________________________________
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

Reply via email to