[Python-ideas] Make Difflib example callable as module __main__

Stephen J. Turnbull stephen at xemacs.org
Fri Feb 24 05:55:10 CET 2012

Georg Brandl writes:

 > > +1 if it will produce git-style unified patches by default
 > > It seems that every single VCS in Python reinvents own differ.
 > "Every single" makes it sounds like there are dozens...
 > Apart from that: a diff/patch algorithm is such an integral part of
 > version control that I would *not* expect them to use difflib, but
 > something more sophisticated/optimized/etc.

But Anatoly isn't talking about the algorithm.  He's talking about the
output, and actually, I would expect them to use something diff(1) and
diff3(1) compatible for hunk-oriented changes.[1]  My experience with
home-grown diff functions suggests that very few produce output as
good as that of diff(1), and only git seems to be an improvement (but
it's not backward compatible, as the tracker/review tool maintainers
regularly mention).

It's true that there are better algorithms than the one used by
diff(1) (such as the "patience diff" Bazaar uses, and git offers as an
option), but there's no need to change the hunk format as far as I
have seen, and the file headers could easily be standardized I would

[1]  Darcs for one allows non-hunk-based changes, specifically a
token-replace patch.  And there are binary diffs such as xdelta, and
word diffs like wdiff, which necessarily use a different format since
they are not line-oriented.

More information about the Python-ideas mailing list