]> granicus.if.org Git - python/commitdiff
Issue #13031: Small speed-up for tarfile when unzipping tarfiles.
authorRoss Lagerwall <rosslagerwall@gmail.com>
Thu, 17 May 2012 17:49:27 +0000 (19:49 +0200)
committerRoss Lagerwall <rosslagerwall@gmail.com>
Thu, 17 May 2012 17:49:27 +0000 (19:49 +0200)
Patch by Justin Peel.

Lib/tarfile.py
Misc/ACKS
Misc/NEWS

index 9d38421ef6eae5c425658613800a804297f8d225..854967751d512910289fc02b8ad4ee1e1e4905e2 100644 (file)
@@ -245,8 +245,8 @@ def calc_chksums(buf):
        the high bit set. So we calculate two checksums, unsigned and
        signed.
     """
-    unsigned_chksum = 256 + sum(struct.unpack("148B", buf[:148]) + struct.unpack("356B", buf[156:512]))
-    signed_chksum = 256 + sum(struct.unpack("148b", buf[:148]) + struct.unpack("356b", buf[156:512]))
+    unsigned_chksum = 256 + sum(struct.unpack_from("148B8x356B", buf))
+    signed_chksum = 256 + sum(struct.unpack_from("148b8x356b", buf))
     return unsigned_chksum, signed_chksum
 
 def copyfileobj(src, dst, length=None):
index b9750b92ae35917210df53da717c4312a8211e21..fc65795c7ab9e2cd2ade736c8e685e8df2410f01 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -776,6 +776,7 @@ GaĆ«l Pasgrimaud
 Joe Peterson
 Randy Pausch
 Samuele Pedroni
+Justin Peel
 Marcel van der Peijl
 Berker Peksag
 Steven Pemberton
index 456f256a2a4dad36a3fe5352408a84d9c9785596..c83d3d36abe49114b6dacb4cafe5e7130f7c7e32 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -38,6 +38,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #13031: Small speed-up for tarfile when unzipping tarfiles.
+  Patch by Justin Peel.
+
 - Issue #14780: urllib.request.urlopen() now has a ``cadefault`` argument
   to use the default certificate store.  Initial patch by James Oakley.