Python implementation of diff.