Comments (2)
Duplicate of #57; both of these are difflib issues.
from icdiff.
I've been having a poke around this afternoon - as #57 points out, icdiff calls difflib._mdiff
, which in turn calls difflib.ndiff
, so that's what I'm using here. Python2 and Python3 both show the following behaviour (which I can't explain, as I haven't delved too deeply into the internals of difflib's algorithm!)
>>> import difflib
>>> list(difflib.ndiff(['aaa'], ['aaa']))
[' aaa']
>>> list(difflib.ndiff(['aaa'], ['baa']))
['- aaa', '+ baa']
>>> list(difflib.ndiff(['aaa'], ['aba']))
['- aaa', '+ aba']
>>> list(difflib.ndiff(['aaa'], ['aab']))
['- aaa', '+ aab']
>>> list(difflib.ndiff(['aaaa'], ['aaaa']))
[' aaaa']
>>> list(difflib.ndiff(['aaaa'], ['baaa']))
['- aaaa', '? -\n', '+ baaa', '? +\n']
>>> list(difflib.ndiff(['aaaa'], ['abaa']))
['- aaaa', '+ abaa']
>>> list(difflib.ndiff(['aaaa'], ['aaba']))
['- aaaa', '? -\n', '+ aaba', '? +\n']
>>> list(difflib.ndiff(['aaaa'], ['aaab']))
['- aaaa', '? ^\n', '+ aaab', '? ^\n']
>>> list(difflib.ndiff(['aaaaa'], ['aaaaa']))
[' aaaaa']
>>> list(difflib.ndiff(['aaaaa'], ['baaaa']))
['- aaaaa', '? -\n', '+ baaaa', '? +\n']
>>> list(difflib.ndiff(['aaaaa'], ['abaaa']))
['- aaaaa', '+ abaaa']
>>> list(difflib.ndiff(['aaaaa'], ['aabaa']))
['- aaaaa', '? -\n', '+ aabaa', '? +\n']
>>> list(difflib.ndiff(['aaaaa'], ['aaaba']))
['- aaaaa', '? -\n', '+ aaaba', '? +\n']
>>> list(difflib.ndiff(['aaaaa'], ['aaaab']))
['- aaaaa', '? ^\n', '+ aaaab', '? ^\n']
>>> list(difflib.ndiff(['aaaaaa'], ['abaaaa']))
['- aaaaaa', '+ abaaaa']
>>> list(difflib.ndiff(['aaaaaaa'], ['abaaaaaaa']))
['- aaaaaaa', '+ abaaaaaaa', '? ++\n']
So it seems difflib is able to sometimes correctly determine the minimum diff (the output lines above containing ?
), but it's somehow sensitive to the length of the matching and non-matching parts of the string and also the position of the non-match?
https://docs.python.org/2/library/difflib.html#difflib.SequenceMatcher sounds like it might be kinda complicated, so perhaps this is already the best that's reasonably possible? shrug
from icdiff.
Related Issues (20)
- update icdiff on pypi.org to latest version HOT 2
- ChangeLog does not mention versions newer than 1.9.4 HOT 1
- BUG: Filenames show as mismatch when using exclusions
- Bug report: configuration for `git icdiff` did not work HOT 2
- installing the latest release-2.0.0 requires different command than install instructions HOT 2
- icdiff doesn't work on windows HOT 2
- Add support to specify colors using RGB ? HOT 1
- Add Support for custom patch hunk headers (with some builtins) HOT 1
- It seems have some problem about utf-8 HOT 1
- git icdiff shows old filname for renamed files HOT 2
- Multi-version of the Python HOT 1
- Exit code 1 using process substitutions HOT 4
- Pip install with `--platform` showing ERROR HOT 2
- [issue] linux more shows empty line. ex) icdiff -N fileA fileB | more -60 HOT 1
- Config file HOT 1
- Feature Request: Add an option to output directories before the files (recursively) HOT 1
- icdiff hanging on large files HOT 5
- Not clear how to install icdiff HOT 2
- Publish wheels for icdiff HOT 3
- Questions about Copilot + Open Source Software Hierarchy HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from icdiff.