2

I checked out the source code of Python 2.6, and I want to study the diff implementation. However, I can not find the right source file. Could any one point me to whichever source file contains the algorithm implementation?

5
  • Um... The source came with your Python implementation. It's on your disk already. What problems are you having finding your Python installation? Commented May 5, 2011 at 13:15
  • 1
    @S.Lott: to be completely fair, if the user installs a binary build (say, on Windows) of Python, it will not come with C sources Commented May 5, 2011 at 13:23
  • @Eli Bendersky: While quite true in general, this question isn't very general, is it? It seems to be about difflib, which is pure Python and already installed. Commented May 5, 2011 at 14:00
  • @S.Lott: yes, but if you look at the OP's comment to Sven's answer, it's obvious he wasn't aware of the fact that difflib is pure Python and was actually looking for the "C code underneath" Commented May 5, 2011 at 14:16
  • Thanks Eli, you are right, difflib is pure Python implementation, which I am not aware of. I think I get my answer. Thanks for anyone. Commented May 6, 2011 at 1:41

1 Answer 1

6

If by "diff implementation in Python" you mean the difflib module, then here is the source.

There is also a simple diff implementation based on this module in the Python source distribution.

2
  • yes, difflib is exactly what I mean. My point is how python use C to implemention this algorithm. So diff.py is not what I wanted. I think the source file should be under the directory of Modules in python source repository. However, I can not find it. Commented May 5, 2011 at 13:02
  • 5
    @user722607: difflib is a pure Python module, there's no C implementation of it Commented May 5, 2011 at 13:09

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.