-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-33234: Add exact allocation optimization to lists in What's New #10200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I will remove that sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 764858a
vstinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: is it "size" or "length"? (len means "length", no?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I used size as the CAPI call is PyObject_Size. Do you prefer to use length ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use length as you suggest :)
https://bugs.python.org/issue33234