On Aug 1, 2012, at 1:46 AM, Mark Shannon wrote:

> 
> '''
> Being able to pre-allocate lists based on the expected size, as estimated by 
> __length_hint__,
> can be a significant optimization.
> PyPy has been observed to run some code slower than CPython, purely because 
> this optimization is absent.
> '''
> 
> Which is a PyPy bug report, not a rationale for a PEP ;)

Alex's rationale is correct and well expressed.

Your proposed revision reflects fuzzy thinking about why __length_hint__ is 
useful.
Regardless of resizing growth factors, it is *always* helpful to know how much
memory to allocate.  Calls to the allocators (especially for large blocks)
and possible the recopying of data should be avoided when possible.


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

Reply via email to