SimpleDiff in Python

A while ago I posted a PHP implementation of a Diff algorithm I came up with[1]. 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.txt (re-name the file to simplediff.py to use)

[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

Posted on Feb 13th, 2008 in Python

Comments

  1. You have ACM access. http://journal-indexes.uwaterloo.ca/

    Comment by Skynet — February 23, 2008 @ 11:46 am

  2. I demand more updates from your blog!

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

    Comment by Peter Kao — February 25, 2008 @ 7:12 pm

  3. 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.

    Comment by Paul — February 25, 2008 @ 7:44 pm

Post a comment

For spam detection purposes, please copy the number 8653 to the field below: