Thu, 30 Nov 2000 16:52:59 +0200
> BTW, one lesson to take from SETL: a vital set operation in practice is a
> mutating "pick a 'random' element E from the set, remove it from the set,
> and return it". An enormous number of set algorithms are of the form
> while not S.empty():
> pick some element from S
> deal with it, possibly mutating S
> This operation can't be done efficiently in Python code if the set is
> represented by a dict (the best you can do is materialize the full list of
> keys first, and pick one of those). That means my Set class often takes
> quadratic time for what *should* be linear-time algorithms.
Hmmm...actually, I've been wanting a method .key() for dictionaries
a long time. So if we give dictionaries this one small method, then
we *can* do this in Python.
Moshe Zadka <email@example.com>
This is a signature anti-virus.
Please stop the spread of signature viruses!