~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tuned_gzip.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-06-05 04:05:05 UTC
  • mfrom: (3473.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080605040505-i9kqxg2fps2qjdi0
Add the 'alias' command (Tim Penhey)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
# make GzipFile faster:
23
23
import gzip
24
 
from gzip import FEXTRA, FCOMMENT, FNAME, FHCRC
 
24
from gzip import U32, LOWU32, FEXTRA, FCOMMENT, FNAME, FHCRC
25
25
import sys
26
26
import struct
27
27
import zlib
32
32
__all__ = ["GzipFile", "bytes_to_gzip"]
33
33
 
34
34
 
35
 
def U32(i):
36
 
    """Return i as an unsigned integer, assuming it fits in 32 bits.
37
 
 
38
 
    If it's >= 2GB when viewed as a 32-bit unsigned int, return a long.
39
 
    """
40
 
    if i < 0:
41
 
        i += 1L << 32
42
 
    return i
43
 
 
44
 
 
45
 
def LOWU32(i):
46
 
    """Return the low-order 32 bits of an int, as a non-negative int."""
47
 
    return i & 0xFFFFFFFFL
48
 
 
49
 
 
50
35
def bytes_to_gzip(bytes, factory=zlib.compressobj,
51
36
    level=zlib.Z_DEFAULT_COMPRESSION, method=zlib.DEFLATED,
52
37
    width=-zlib.MAX_WBITS, mem=zlib.DEF_MEM_LEVEL,