find_longest_match in SequenceMatcher

koara koara at atlas.cz
Sun Jul 23 17:22:14 EDT 2006


Hello, it might be too late or too hot, but i cannot work out this
behaviour of find_longest_match() in difflib.SequenceMatcher:

string1:
releasenotesforwildmagicversion01thiscdromcontainstheinitialreleaseofthesourcecodethataccompaniesthebook"3dgameenginedesign:apracticalapproachtorealtimecomputergraphics"thereareanumberofknownissuesaboutthecodeastheseissuesareaddressedtheupdatedcodewillbeavailableatthewebsitehttp://wwwmagicsoftwarecom/3dgameenginedesignhtmlbugssuggestionsforimprovementsandothercorrespondencecanbesenttosupport@magicsoftwarecomthecurrentknownissuesare1meshalgorithmforcontinuouslevelofdetailappearsnottobeworkingbase

string2:
releasenotesforwildmagicversion02updatefromversion01toversion02ifyourcopyofthebookhasversion01andifyoudownloadedversion02fromthewebsitethenapplythefollowingdirectionsforinstallingtheupdateforalinuxinstallationseethesectionattheendofthisdocumentupdatedirectionsassumingthatthetopleveldirectoryiscalledmagicreplacebyyourtoplevelnameyoushouldhavetheversion01contentsinthislocation1deletethecontentsofmagic\include2deletethesubdirectorymagic\source\mgcapplication3deletetheobsoletefiles:amagic\source\mgc

find_longest_match(0,500,0,500)=(24,43,10)="version01t"

What? O_o Clearly there is a longer match, right at the beginning!
And then, after removal of the last character from each string (i found
the limit of 500 by trial and error -- and it looks suspiciously
rounded):

find_longest_match(0,499,0,499)=(0,0,32)="releasenotesforwildmagicversion0"


Is this the expected behaviour? What's going on?
Thank you for any ideas




More information about the Python-list mailing list