Hello,

I was told by someone (as a comment) that a code snippet such as this
"would make Pythonistas talk my ear off about how evil the append()"
function is:

>>> mylist = []
>>> mylist.append(1)
# a number of times over

I have some ideas that on an append() the list's internal size
increases (doubled?) since CPython over-allocates memory, and such.

So, the question is: what is the alternative to growing a list when I
have no idea what items or how many may be there?


Thanks,
Amit.

-- 
http://echorand.me
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to