Whitespace and spelling fixes.

This commit is contained in:
Alex Gaynor 2012-07-29 18:10:33 -07:00
parent 162406d485
commit 9962846ad1
1 changed files with 5 additions and 3 deletions

View File

@ -28,8 +28,9 @@ interpreter and non-standard library Python to implement.
``__length_hint__`` must return an integer (else a TypeError is raised) or ``__length_hint__`` must return an integer (else a TypeError is raised) or
``NotImplemented, and is not required to be accurate. It may return a value ``NotImplemented, and is not required to be accurate. It may return a value
that is either larger or smaller than the actual size ofthe container. A return value of ``NotImplemented`` indicates that there is no finite length estimate. that is either larger or smaller than the actual size of the container. A
It may not return a negative value (else a ValueError is raised). return value of ``NotImplemented`` indicates that there is no finite length
estimate. It may not return a negative value (else a ValueError is raised).
In addition, a new function ``operator.length`` hint is added, having the In addition, a new function ``operator.length`` hint is added, having the
follow semantics (which define how ``__length_hint__`` should be used:: follow semantics (which define how ``__length_hint__`` should be used::
@ -66,7 +67,8 @@ return value for objects which do not provide a length or length hint.
Rationale Rationale
========= =========
Being able to pre-allocate lists based on the expected size, as estimated by ``__length_hint__``, can be a significant optimization. CPython has been Being able to pre-allocate lists based on the expected size, as estimated by
``__length_hint__``, can be a significant optimization. CPython has been
observed to run some code faster than PyPy, purely because of this optimization observed to run some code faster than PyPy, purely because of this optimization
being present. being present.