On Fri, 23 Dec 2011 09:44:31 +0000, Steven D'Aprano wrote: > On Fri, 23 Dec 2011 09:28:52 +0100, Peter Otten wrote: > >>> -proper & efficient detection of file-change, to know whether the user >>> actually did anything >> >> Just read the whole thing back into memory and compare the string to >> the original data. The file has to be quite long for the checksum >> calculation to be worthwhile. > > I don't think so. No matter how long the file is, the checksum is always > going to do far more work than a simple string comparison. A string > comparison can short-circuit on the first difference; the checksum must > always process both files in their entirety.
Wait... the above only holds assuming you keep both the before-editing and after-editing versions. If you don't, then Peter is right, there comes a point where keeping a checksum saves enough memory for the additional effort to be worth while. Sorry for the noise. -- Steven -- http://mail.python.org/mailman/listinfo/python-list