Message 337780 - Python tracker

Message337780

Author brandtbucher
Recipients brandtbucher, pablogsal, rhettinger, serhiy.storchaka
Date 2019-03-12.17:21:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552411260.35.0.852819815546.issue36229@roundup.psfhosted.org>
In-reply-to
Content
Thank for the input, Serhiy. On point (1):

It's a valid concern... but I don't think it's necessarily a good enough reason to withhold a simple, yet *significant* performance increase for a common use case.

This reminds me of past CPython implementation details, such as ordered dictionaries in 3.6. Some users may errantly adopt problematic idioms that aren't strictly portable between implementations, but if you ask me the performance improvement (again, from quadratic to linear) for three common built-in types (I admit I'm being a bit generous to bytearray here ;) is well worth it.

Regarding (2): 

I believe that CPython lists only overallocate by something like 1/8, which in my opinion is a fairly conservative value. If the lists are large enough for this small preallocation to be a real memory burden, I would imagine that making the extra copies would be even worse.

And, if you ask me, list overallocation is a feature, not a bug!
History
Date User Action Args
2019-03-12 17:21:00brandtbuchersetrecipients: + brandtbucher, rhettinger, serhiy.storchaka, pablogsal
2019-03-12 17:21:00brandtbuchersetmessageid: <1552411260.35.0.852819815546.issue36229@roundup.psfhosted.org>
2019-03-12 17:21:00brandtbucherlinkissue36229 messages
2019-03-12 17:21:00brandtbuchercreate