Palindrome finder: help find ways to speed up?

Scott David Daniels Scott.Daniels at Acm.Org
Tue Apr 8 20:28:54 EDT 2003


Dave Brueck wrote:
> ...
> def IsPal(s):
>   r = list(s)
>   r.reverse()
>   r = ''.join(r)
>   ...

This bit should go significantly faster with array:

     from array import array

     def IsPal(s):
        t = array('c', s)
        t.reverse()
        r = t.tostring()

-Scott David Daniels
Scott.Daniels at Acm.Org






More information about the Python-list mailing list