Hi all,

python now supports the __length_hint__ method but not for every use
case that could potentially benefit from it, v.g.:

1) Some common builtins like map don't set the hint.
2) Generators.
3) Application specific hints that, by definition, can't be predicted
by a general strategy.

I know 1 and 2 were discussed at some length in the past, but still
there is no agreement about what to do with them.

In the meantime, and because of 3, what do you think about adding a
simple iterator wrapper to itertools which would allow to provide the
hint by the user without any significant performance lost (__next__ in
the wrapper could be just the original __next__). AFAIK there is no
such thing in the standard library or anywhere else and it seems
pretty easy to implement, although maybe I'm completely wrong.

Say:

hinted_iter = it.length_hint(iter, hint)

Cheers
--
Carlos
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to