There's got to be an easy way to do this
Terry Reedy
tjreedy at home.com
Thu Jul 5 14:58:53 EDT 2001
"Emile van Sebille" <emile at fenx.com> wrote in message
news:9i2c77$gmc74$1 at ID-11957.news.dfncis.de...
> I'm not sure how you mean slower, but I tested just now to see, and this
is
> the fastest of the four.
> def str_join(iters):
> for i in iters:
> "".join([x for x in '(123)/456-7890' if x in '0123456789'])
This could use either conditional '0' <= x <= '9' with 2 compares instead
of average 5.5
or x.isdigit() from below.
>
> def flt_lmbda(iters):
> for i in iters:
> filter(lambda c:c.isdigit(), '(123)/456-7890')
would two compares be faster than one func call?
TJ Reedy
More information about the Python-list
mailing list