find_longest_match in SequenceMatcher

John Machin sjmachin at lexicon.net
Mon Jul 24 18:53:51 EDT 2006


koara wrote:
> John Machin wrote:
> > --test results snip---
> > Looks to me like the problem has nothing at all to do with the length
> > of the searched strings, but a bug appeared in 2.3.  What version(s)
> > were you using? Can you reproduce your results (500 & 499 giving
> > different answers) with the same version?
>
> Hello John, thank you for investigating and responding!
>
> Yes, I can reproduce the behaviour with different results within the
> same version -- which is 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310
> 32 bit (Intel)]
>
> The catch is to remove the last character, as i described in my
> original post, as opposed to passing reduced length parameters to
> find_longest_match, which is what you did.
>
> It is morning now, but i still fail to see the mistake i am making --
> if it is indeed a bug, where do i report it?
>

Further sniffing shows that we were both partially right/wrong:
There is a bug.
It is length-dependant.
It was introduced in Python 2.3.

If you want to, you can hack your copy of
<Python-2.4_installation_directory>/Lib/difflib.py
so that line 316 reads:
    if 0:
instead of:
    if n >= 200 and len(indices) * 100 > n:

I'll report it.

Cheers,
John




More information about the Python-list mailing list