delete duplicates in list

Michael Hudson mwh at python.net
Thu Oct 30 05:56:27 EST 2003


Alex Martelli <aleax at aleax.it> writes:

> > Actually the Set in sets module has an average lookup of O(1), worst
> > case O(n) (not 100% sure of worst case, but 99% sure). It's been
> 
> Hmmm -- could you give an example of that worstcase...?  a _full_
> hashtable would give such behavior, but Python's dicts always ensure
> the underlying hashtables aren't too full...

Try inserting a bunch of instances of 

class C:
    def __hash__(self): return 0

into a dictionary.

Cheers,
mwh

-- 
  Whaaat? That is the most retarded thing I have seen since, oh,
  yesterday                             -- Kaz Kylheku, comp.lang.lisp




More information about the Python-list mailing list