bpo-33234: Add exact allocation optimization to lists in What's New#10200
bpo-33234: Add exact allocation optimization to lists in What's New#10200pablogsal merged 3 commits intopython:masterfrom
Conversation
Doc/whatsnew/3.8.rst
Outdated
| * The :class:`list` constructor does not overallocate the internal item buffer | ||
| if the input iterable has a known size (the input implements ``__len__``). | ||
| This makes the created list 12% smaller on average and it speeds the creation | ||
| of very large lists. (Contributed by Pablo Galindo in :issue:`33234`.) |
There was a problem hiding this comment.
"and it speeds the creation of very large lists" even if it's true, I'm not sure that it's worth it to mention it. The most important part is the memory footprint, no?
There was a problem hiding this comment.
Yup, I will remove that sentence.
vstinner
left a comment
There was a problem hiding this comment.
LGTM, but I have a last question :-)
Doc/whatsnew/3.8.rst
Outdated
| that arbitrary attributes can no longer be added to them. | ||
|
|
||
| * The :class:`list` constructor does not overallocate the internal item buffer | ||
| if the input iterable has a known size (the input implements ``__len__``). |
There was a problem hiding this comment.
nitpick: is it "size" or "length"? (len means "length", no?)
There was a problem hiding this comment.
Yup, I used size as the CAPI call is PyObject_Size. Do you prefer to use length ?
There was a problem hiding this comment.
Honestly, it's not important, so it's up to you :-) The doc says "length":
https://docs.python.org/dev/reference/datamodel.html#object.__len__
For me, "size" means more number of bytes, and "length" or "count" the number of items. But I'm used to the C language which is different :-)
There was a problem hiding this comment.
Let's use length as you suggest :)
https://bugs.python.org/issue33234