SimpleDiff in Python

A while ago I posted a PHP implementation of a diff algorithm I came up with1. Since it was well received, and it’s a useful little algorithm to have, I created a Python version as well.

There are a few performance improvements as well. The PHP version creates an array in memory proportional to the square of the size of the input, while the Python version’s array is directly proportional to the size of the input. I also sped up how the algorithm finds the indexes of the “new” elements in the “old” array.

Download simplediff.py

1 It is probably the same algorithm that others use, but I haven’t gotten around to getting an ACM membership to access the related papers

6 Comments

  1. Peter Kao says:

    I demand more updates from your blog!

    Do a post on your involvement with AideRss…I’m all ears :)

  2. Paul says:

    Skynet, cool, thanks. That will come in handy.

    Peter, yeah, I should really update more. I’ll let you know about my summer plans once I figure them out. At the moment I’m torn between a couple opportunities.

  3. Dheenadhayalan says:

    The algorithm implementation is pretty cool.. can u just give me the C# implementation.. it would be of great help to me

  4. Dheenadhayalan says:

    if you are not able to give C# implementation, give the pseudo code of your implementations of diff algorithms..

  5. monika says:

    The algorithm implementation is pretty cool..

Leave a Reply