list.without()?
Christian Tismer
tismer at appliedbiometrics.com
Tue Nov 16 15:28:07 EST 1999
Mike Fletcher wrote:
>
> Hmm, actually, it's only cheap for certain subsets of the problem (which I
> took to be the common case). In particular, it shines for small numbers of
> instances in lists of fairly arbitrary size. It falls down completely when
> you are removing large numbers of instances (such as all of them). I just
> tested five algos, testing 1 instance in middle of list, and a list composed
> of only elements to be removed, findings, module, and raw test results
> below...
Oh well, I overlooked that you have the try inside the while.
That's bad. I thought I had read this:
def without( source, element):
temp = source[:]
try:
while temp:
temp.remove( element )
except:
return temp
return temp
Did you try this (I didn't, have no time).
cheers - chris
--
Christian Tismer :^) <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net
10553 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
we're tired of banana software - shipped green, ripens at home
More information about the Python-list
mailing list