Gregory P. Smith added the comment:

The gain will be more noticeable the faster the Python implementation it is 
running under is. It is going to avoid logN relloc's in just about all 
implementations.  That CPython is relatively slow is not a justification to 
avoid adding the feature.

I like Christian's proposal of not having it be a constructor argument but 
having it be a __preallocate__ method on the object.  That keeps it out of the 
eyes of most users reading the docs (keeping the main interface clear) and lets 
us put it in a special section of the python docs.  Code that *needs* it could 
use it but most would not need to bother.

Python VMs would be free to have dummy do nothing implementations (ie: we 
should *never* guarantee that a python call to thing.__preallocate__(1000) 
followed immediately by a C extension module call that takes thing as input can 
assume anything about the underlying object... it needs to check the size or 
resize itself before using the unchecked _SET_ITEM macros, etc.)

----------
nosy: +gregory.p.smith

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17338>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to