Author Peter.Waller
Recipients Peter.Waller, chipx86, collinwinter, ggenellina, loewis, rhettinger, tfaing, tim.peters
Date 2010-02-28.13:57:20
SpamBayes Score 0.00204032
Marked as misclassified No
Message-id <1267365442.92.0.454155632819.issue1711800@psf.upfronthosting.co.za>
In-reply-to
Content
Here is a patch against 2.6.4.

A brief description of how it works:

If we're emitting a "replace" with unequal lengths, then instead emit a replace followed by an insert or delete to make up for the difference in length.

My code to see that it works:

a = "aa bbb cc D"
b = "aa czbb cc E"

sm = difflib.SequenceMatcher(None, a, b).get_opcodes()

print "A = ", a
print "B = ", b

for o in opcodes:
    tag, i1, i2, j1, j2 = o
    print "%30r %-20s %-20s" % (o, a[i1:i2], b[j1:j2])
History
Date User Action Args
2010-02-28 13:57:23Peter.Wallersetrecipients: + Peter.Waller, tim.peters, loewis, collinwinter, rhettinger, ggenellina, chipx86, tfaing
2010-02-28 13:57:22Peter.Wallersetmessageid: <1267365442.92.0.454155632819.issue1711800@psf.upfronthosting.co.za>
2010-02-28 13:57:21Peter.Wallerlinkissue1711800 messages
2010-02-28 13:57:20Peter.Wallercreate