longest sequence
Anton Vredegoor
anton at vredegoor.doge.nl
Wed Feb 19 16:47:09 EST 2003
On Mon, 17 Feb 2003 18:53:55 -0600, "Mark McEahern"
<marklists at mceahern.com> wrote:
>Thanks to everyone who replied. The following test code generates the
>following results on my Windows machine under cygwin's Python 2.2.1. I've
>included all suggestions made in the thread so far and modified the
>longest_dsu and longest_max functions with Tim's advice above:
>
> longest_for --> 0.14 sec
> longest_dsu --> 0.25 sec
> longest_max --> 0.30 sec
> longest --> 0.40 sec
[snip the code]
Thanks for posting the test-code. This makes it easy to compare
different solutions. This one is currently fastest here:
def longest_func(*args):
L=map(len,args)
return args[L.index(max(L))]
Regards,
Anton.
More information about the Python-list
mailing list