difflib.SequenceMatcher fails for larger strings

Thomas tavspam at gmail.com
Tue Dec 12 22:59:10 CET 2006


I'm trying to write a program to test a persons typing speed and show
them their mistakes. However I'm getting weird results when looking
for the differences in longer strings:

import difflib

a = '01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'

# now with a few mistakes
b = '012345W7890123456789012W456789012345678901W3456789012345678901234567890W234567890123456789012345W789012345678901234567890123W567890123456W89012345678901234567W90123456789012W4567890123456W890123456789'

s = difflib.SequenceMatcher(None, a, b)

print s.get_matching_blocks()
print s.get_opcodes()

Is this a known bug? Would it just take to long to calculate?


More information about the Python-bugs-list mailing list