Skip to content

Conversation

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Oct 28, 2018

@pablogsal pablogsal self-assigned this Oct 28, 2018
@pablogsal pablogsal requested a review from vstinner October 28, 2018 20:48
@bedevere-bot bedevere-bot added docs Documentation in the Doc dir awaiting merge labels Oct 28, 2018
* 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`.)
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 764858a

Copy link
Member

@vstinner vstinner left a 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 :-)

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__``).
Copy link
Member

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?)

Copy link
Member Author

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 ?

Copy link
Member

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 :-)

Copy link
Member Author

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 :)

@pablogsal pablogsal merged commit c61e229 into python:master Oct 28, 2018
@pablogsal pablogsal deleted the optimizations branch October 28, 2018 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants