[Python-Dev] PEP 0424: A method for exposing a length hint (original) (raw)
Stefan Behnel stefan_ml at behnel.de
Mon Jul 16 08:54:27 CEST 2012
- Previous message: [Python-Dev] PEP 0424: A method for exposing a length hint
- Next message: [Python-Dev] PEP 0424: A method for exposing a length hint
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mark Shannon, 15.07.2012 16:14:
Alex Gaynor wrote:
CPython currently defines an
_lengthhint_
method on several types, such as various iterators. This method is then used by various other functions (such asmap
) to presize lists based on the estimated returned by Don't use "map" as an example. map returns an iterator so it doesn't need lengthhint
Right. It's a good example for something else, though. As I mentioned before, iterators should be able to propagate the length hint of an underlying iterator, e.g. in generator expressions or map(). I consider that an important feature that the protocol must support.
Stefan
- Previous message: [Python-Dev] PEP 0424: A method for exposing a length hint
- Next message: [Python-Dev] PEP 0424: A method for exposing a length hint
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]