mwh at python.net
Fri Jun 14 05:33:10 EDT 2002
huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) writes:
> It's not that gross, but it only gives 14% speedup, though.
Oh yeah. What you've done is kind of obvious...
> def filter2a(test, list):
> l1 = 
> l2 = 
> funcs = [l1.append, l2.append]
> map(lambda x: funcs[not test(x)](x), list)
> return l1, l2
> BTW, what's the reason that using a list for funcs is faster than using a
> tuple (as observed under Python 2.2.1 on Linux)?
Look at BINARY_SUBSCR in ceval.c... list[int] is special-cased.
Ability to type on a computer terminal is no guarantee of sanity,
intelligence, or common sense.
-- Gene Spafford's Axiom #2 of Usenet
More information about the Python-list