[Python-Dev] Fwd: summing a bunch of numbers (or "whatevers")

Barry Warsaw barry@python.org
22 Apr 2003 22:42:01 -0400


On Tue, 2003-04-22 at 21:35, Greg Ward wrote:
> On 21 April 2003, Tim Peters said:
> > filter() is hard to get rid of because the bizarre filter(None, seq) special
> > case is supernaturally fast.  Indeed, time the above against
> 
> Hmmm, a random idea: has filter() ever been used for anything else?
> I didn't think so.  So why not remove everything *except* that handy
> special-case: ie. in 3.0, filter(seq) == filter(None, seq) today, and
> that's *all* filter() does.

I've never used it for anything else, but I'm also just as happy to use

[x for x in seq if x]

Although it's a bit verbose, TOOWTDI.

-Barry