I've used winmerge for years which I am mainly happy with. My one issue with it, and other diff tools I've tried (diffuse, Meld, Beyond Compare) is when code is changed in a small way and indented, it thinks the whole block changed entirely. Contrived code example:

def func(obj):                      def func(objs):
                                        for obj in objs:
    x, y, z = obj.getPos() ==>              x, y, z = obj.getPos()
    l = calcLen(x, y, z)                    l = calcLen(x, y, z)

What I want is to see that the 's' got added to obj, that for obj in objs: was added and that the code below was indented. Instead, every tool I've used ends up comparing x, y, z = obj.getPos() to for obj in objs:. Sometimes the (now indented) block has small changes, and that is the point, I want to see them as the small changes they are instead as false positive big changes.

It is possible that something I've mentioned does this but I haven't figured out where that setting is.

Right now what I do is edit the diff to unindent the code, often deleting the added code that caused the indent to get it to actually isolate my real changes. It's a really cumbersome process and error prone since I have to copy snippets out to the real file instead of leverage the diff tool.

  • I'm a fan of TkDiff myself. See screenshot on that page as illustration of small inserts in lines. Adjust options to taste.
    – Jason C
    May 19, 2015 at 5:44

3 Answers 3


Not python specific but kdiff3, and most other diff tools, has a ignore number of spaces setting via one mechanism or another.

In kdiff3 you can also set filters using regex syntax to run on both files before comparing.

Of course since indentation is actually very significant in python using pylint or pep-8 checks on all files will tend to avoid indentation only differences unless they are significant.

  • Correct. Both WinMerge & Beyond Compare, which the OP mentions, can ignore whitespace.
    – Mawg
    May 20, 2015 at 8:45

I asked some friends and one thought the PyCharm diffed python well. I tried it on my sample, and some real code, and it worked how I hoped: small changes to indented blocks were displayed as small changes with indentation.


For Python I use DiffTool to compare files. For the issues like you wrote it works perfect. OK, it runs on Android only but I do a lot of work on my mobile and here it handles your issue in a perfect way. On your example only the "s" of objs and the line with the "for ..." is marked as insertions. So if you do some of your work on travel, like I do see this link:


On my PC I use KDiff3. I did a lot of tests and my personal feeling is that this Android tool is faster and more precise than KDiff3. Additionally: DiffTool can compare content of ZIP, APK and JAR archives. DiffTool can compare Binary Files too. DiffTool can also compare the text of *.docx or *.xlsx documents. I would be happy if this tool would be available on PC too. But I found it for Android only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.