STINNER Victor <vstin...@redhat.com> added the comment:

The main issue with using length hint is that calling a method is Python is not 
free. Calling the method may add more overhead than the speedup provided by 
smarter memory allocations.

The worst case for this optimization should be measured on very small data set, 
of less than 10 items. We don't want to make Python smaller for operations on 5 
items for example.

The idea which remains open is the idea of adding a "slot" for length hint in 
PyTypeObject. But I would suggest to open a separated issue to explore this 
idea.

Slots allows to use C functions at raw speed and so reduce the cost of getting 
the length hint.

----------

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

Reply via email to