[Python-checkins] CVS: python/dist/src/Lib filecmp.py,1.3,1.4
Guido van Rossum
python-dev@python.org
Tue, 28 Mar 2000 16:42:41 -0500 (EST)
- Previous message: [Python-checkins] CVS: python/dist/src/PCbuild winreg.dsp,NONE,1.1 pcbuild.dsw,1.6,1.7
- Next message: [Python-checkins] CVS: python/dist/src/Lib ftplib.py,1.41,1.42 gopherlib.py,1.6,1.7 httplib.py,1.14,1.15 imaplib.py,1.19,1.20 nntplib.py,1.18,1.19 poplib.py,1.7,1.8 smtplib.py,1.22,1.23
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /projects/cvsroot/python/dist/src/Lib
In directory eric:/projects/python/develop/guido/src/Lib
Modified Files:
filecmp.py
Log Message:
Fredrik Lundh:
The new filecmp module has an optional argument called use_statcache
which is documented as a true/false value, but used as an tuple index.
This patches replaces the tuple stuff with a good old if- statement,
and also removes a few other tuple pack/unpack constructs (if not
else, this saves a few bytes in the PYC file, and a few microseconds
when using the module ;-).
Index: filecmp.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/filecmp.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** filecmp.py 2000/02/04 15:10:32 1.3
--- filecmp.py 2000/03/28 21:42:38 1.4
***************
*** 31,42 ****
"""
! stat_function = (os.stat, statcache.stat)[use_statcache]
! s1, s2 = _sig(stat_function(f1)), _sig(stat_function(f2))
! if s1[0]!=stat.S_IFREG or s2[0]!=stat.S_IFREG: return 0
! if shallow and s1 == s2: return 1
! if s1[1]!=s2[1]: return 0
result = _cache.get((f1, f2))
! if result and (s1, s2)==result[:2]:
return result[2]
outcome = _do_cmp(f1, f2)
--- 31,49 ----
"""
! if use_statcache:
! stat_function = statcache.stat
! else:
! stat_function = os.stat
! s1 = _sig(stat_function(f1))
! s2 = _sig(stat_function(f2))
! if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG:
! return 0
! if shallow and s1 == s2:
! return 1
! if s1[1] != s2[1]:
! return 0
result = _cache.get((f1, f2))
! if result and (s1, s2) == result[:2]:
return result[2]
outcome = _do_cmp(f1, f2)
***************
*** 51,57 ****
def _do_cmp(f1, f2):
bufsize = BUFSIZE
! fp1 , fp2 = open(f1, 'rb'), open(f2, 'rb')
while 1:
! b1, b2 = fp1.read(bufsize), fp2.read(bufsize)
! if b1!=b2: return 0
! if not b1: return 1
--- 58,68 ----
def _do_cmp(f1, f2):
bufsize = BUFSIZE
! fp1 = open(f1, 'rb')
! fp2 = open(f2, 'rb')
while 1:
! b1 = fp1.read(bufsize)
! b2 = fp2.read(bufsize)
! if b1 != b2:
! return 0
! if not b1:
! return 1
- Previous message: [Python-checkins] CVS: python/dist/src/PCbuild winreg.dsp,NONE,1.1 pcbuild.dsw,1.6,1.7
- Next message: [Python-checkins] CVS: python/dist/src/Lib ftplib.py,1.41,1.42 gopherlib.py,1.6,1.7 httplib.py,1.14,1.15 imaplib.py,1.19,1.20 nntplib.py,1.18,1.19 poplib.py,1.7,1.8 smtplib.py,1.22,1.23
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]