alwayssortedlist (was Re: On PEP 322 (ireverse))
Alex Martelli
aleaxit at yahoo.com
Thu Oct 30 14:49:27 EST 2003
Jeremy Fincher wrote:
> Alex Martelli <aleax at aleax.it> wrote in message
> news:<HaVnb.65220$e5.2392011 at news1.tin.it>...
>> Perfectly right. If you DO want a listoid container that keeps its
>> elements sorted, that's not hard to make for yourself. There are
>> basically two obvious implementation strategies:
>> -- ensure the underlying list is re-sorted at each insertion,
>> append &c, and/or
...
> Any reason he shouldn't just use bisect.insort?
What about measuring the performance of the two approaches?
I've shown how incredibly simple the sort-after-whatever-addition-
or-replacement approach is -- the insort one will require some more
coding, but IF it's a lot faster, sure. But don't discount timsort's
performance -- it's often incredibly good.
Alex
More information about the Python-list
mailing list