Question about `list.insert`
rosuav at gmail.com
Fri Feb 7 04:20:43 CET 2014
On Fri, Feb 7, 2014 at 2:11 PM, Tim Chase <python.list at tim.thechases.com> wrote:
> On 2014-02-06 22:00, Roy Smith wrote:
>> > list does not promise better than O(1) behavior
>> I'm not aware of any list implementations, in any language, that
>> promises better than O(1) behavior for any operations. Perhaps
>> there is O(j), where you just imagine the operation was performed?
> Pish...there's always O(0) which is achieved by *not* performing some
> unneeded operation ;-)
Ooh! Ooh! I got it!
if len(self) and randrange(len(self)): return
Repeated appends to this list are amortized O(0)!
More information about the Python-list