list.without()?
Mike Fletcher
mcfletch at vrtelecom.com
Tue Nov 16 15:53:56 EST 1999
Shouldn't make a big difference, as they exception only occurs once (when
you're out of elements to remove). Doesn't challenge the front-runners
anyway.
Enjoy,
Mike
# Following just ran the original without and Chris' as without6
p:\>without
Testing function: <function without at 7d7f00>
single element at middle:
10: 0.0
100: 0.0
1000: 0.0
10000: 0.00999999046326
100000: 0.0699999332428
1000000: 1.11199998856
all elements being removed:
10: 0.120000004768
100: 0.0
1000: 0.0100001096725
10000: 0.770999908447
100000: 78.7929999828
###Note: Tests skipped due to time overrun
Testing function: <function without6 at 7e0340>
single element at middle:
10: 0.0
100: 0.0
1000: 0.0
10000: 0.0
100000: 0.0710000991821
1000000: 1.10099995136
all elements being removed:
10: 0.129999995232
100: 0.0
1000: 0.00999999046326
10000: 0.761000037193
100000: 79.8550000191
###Note: Tests skipped due to time overrun
-----Original Message-----
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of Christian Tismer
Sent: November 16, 1999 3:28 PM
To: Mike Fletcher
Cc: python-list at python.org
Subject: Re: list.without()?
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
--
http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list