[Python-Dev] Idea: __length_hint__ wrapper in itertools

2015-02-20 Thread Carlos Pita
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


[Python-Dev] __qualname__ exposed as a local variable: standard?

2016-07-07 Thread Carlos Pita
Hi all,

I noticed __qualname__ is exposed by locals() while defining a class. This
is handy but I'm not sure about its status: is it standard or just an
artifact of the current implementation? (btw, the pycodestyle linter
-former pep8- rejects its usage). I was unable to find any reference to
this behavior in PEP 3155 nor in the language reference.

Thank you in advance
--
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