[Python-Dev] Do we need length_hint at all? (Was PEP 0424: A method for exposing a length hint) (original) (raw)

Stefan Behnel stefan_ml at behnel.de
Mon Jul 16 11:02:42 CEST 2012


Mark Shannon, 16.07.2012 10:37:

If resizing of lists is too slow, then we should reconsider the 9/8 factor and/or look to tweak the resizing code.

The thing is that the performance is platform specific. On systems with a fast memory allocator, especially on Linux, the difference is negligible. However, with a slow memory allocator, especially a slow realloc(), e.g. on Windows or Solaris, this can substantially hurt the performance, up to a quadratically increasing runtime in the worst case.

The length hint was implemented specifically to work around this problem.

Stefan



More information about the Python-Dev mailing list