Andrei, if you have missed it, you can take a look at this simple API of mine:
http://code.activestate.com/recipes/502295/

This is the constructor (well almost, in Python the constructor is __new__), it 
uses an optional key function, instead of a cmp:
def __init__(self, sequence=None, key=None, inplace=False):

"inplace" allows it to not copy items if the given sequence is a list (that is 
a dynamic array).
inplace is False by default, to increase safety and reduce surprises, so the 
default design is nice and safe. When your profiling or your brain tells you 
need more speed, that can be as efficient as your implementation (because lists 
are very commonly used data structures in Python, so most of the times your 
items are already in a list).
In D probably a cmp function is faster than a key (because a key needs to 
allocate new memory), but 99% of the times the key is nicer to use.

Bye,
bearophile

Reply via email to