This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients MSeifert, alex, nmusolino, rhettinger, serhiy.storchaka, terry.reedy, vstinner
Date 2019-06-27.23:33:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561678432.11.0.490795868198.issue26828@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-06-27 23:33:52vstinnersetrecipients: + vstinner, rhettinger, terry.reedy, alex, serhiy.storchaka, MSeifert, nmusolino
2019-06-27 23:33:52vstinnersetmessageid: <1561678432.11.0.490795868198.issue26828@roundup.psfhosted.org>
2019-06-27 23:33:52vstinnerlinkissue26828 messages
2019-06-27 23:33:51vstinnercreate