Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65582
| References | <4041bba7-91bc-4803-9150-2fcf14ecb5a9@googlegroups.com> <mailman.6471.1391741496.18130.python-list@python.org> <roy-5342A1.22005606022014@news.panix.com> <20140206211130.3ec5b0d8@bigbox.christie.dr> |
|---|---|
| Date | 2014-02-07 14:20 +1100 |
| Subject | Re: Question about `list.insert` |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6474.1391743247.18130.python-list@python.org> (permalink) |
On Fri, Feb 7, 2014 at 2:11 PM, Tim Chase <python.list@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 ;-)
>
> -tkc
Ooh! Ooh! I got it!
class fast_list(list):
def append(self,obj,randrange=random.randrange):
if len(self) and randrange(len(self)): return
return super().append(obj)
Repeated appends to this list are amortized O(0)!
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Question about `list.insert` cool-RR <ram.rachum@gmail.com> - 2014-02-06 15:59 -0800
Re: Question about `list.insert` Terry Reedy <tjreedy@udel.edu> - 2014-02-06 19:40 -0500
Re: Question about `list.insert` MRAB <python@mrabarnett.plus.com> - 2014-02-07 00:42 +0000
Re: Question about `list.insert` Terry Reedy <tjreedy@udel.edu> - 2014-02-06 21:48 -0500
Re:Question about `list.insert` Dave Angel <davea@davea.name> - 2014-02-06 21:54 -0500
Re: Question about `list.insert` Roy Smith <roy@panix.com> - 2014-02-06 22:00 -0500
Re: Question about `list.insert` Rustom Mody <rustompmody@gmail.com> - 2014-02-06 19:08 -0800
Re: Question about `list.insert` Tim Chase <python.list@tim.thechases.com> - 2014-02-06 21:11 -0600
Re: Question about `list.insert` Roy Smith <roy@panix.com> - 2014-02-06 22:12 -0500
Re: Question about `list.insert` Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-07 17:18 +1300
Re: Question about `list.insert` Chris Angelico <rosuav@gmail.com> - 2014-02-07 14:14 +1100
Re: Question about `list.insert` Chris Angelico <rosuav@gmail.com> - 2014-02-07 14:20 +1100
Re: Question about `list.insert` Rustom Mody <rustompmody@gmail.com> - 2014-02-06 19:29 -0800
Re: Question about `list.insert` Chris Angelico <rosuav@gmail.com> - 2014-02-07 14:45 +1100
Re: Question about `list.insert` Asaf Las <roegltd@gmail.com> - 2014-02-06 19:28 -0800
Re: Question about `list.insert` Dan Stromberg <drsalists@gmail.com> - 2014-02-06 20:52 -0800
Re: Question about `list.insert` Asaf Las <roegltd@gmail.com> - 2014-02-06 21:18 -0800
Re: Question about `list.insert` Peter Otten <__peter__@web.de> - 2014-02-07 09:25 +0100
csiph-web