list.sort(func) speed

Chad Netzer cnetzer at sonic.net
Sun Aug 31 23:08:43 CEST 2003


On Sun, 2003-08-31 at 13:33, mackstann wrote:

> No, but the thought of inserting things in order did not quite occur to
> me.  Can you give me an simple example of exactly how to go about this?

Don't have time for an example at the moment.  But the bisect module
will do it for you.

help('bisect')
help('bisect.insort')

The basic way in which it works (I assume, having not looked at the
code), is a binary search algorithm, which is very fast.

-- 
Chad Netzer






More information about the Python-list mailing list