[issue8905] difflib should accept arbitrary line iterators

Terry J. Reedy report at bugs.python.org
Tue Mar 19 09:20:15 CET 2013


Terry J. Reedy added the comment:

'difflib' is a module that defines three classes and some functions. It does not do anything in itself. SequenceMatcher, which is the basis for the other functions, operates on sequences of hashable objects. The inputs must be concrete random access indexed sequences because SequenceMatcher scans the inputs and then jumps around finding good matches and the complementary differences. It is completely unlike functions that take iterables as arguments and than call iter to get an iterator. If S-M took iterables as inputs, it would have to either copy all inputs with list (bad) or figure out whether or not to copy. I think users can continue to pass file.readlines() or list(iterable) as needed.

The two functions that mistakenly say inputs are 'lists' instead of 'sequences' will be fixed at part of another issue.

----------
nosy: +terry.reedy
resolution:  -> works for me
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8905>
_______________________________________


More information about the Python-bugs-list mailing list