~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tuned_gzip.py

  • Committer: Ian Clatworthy
  • Date: 2009-12-03 23:21:16 UTC
  • mfrom: (4852.4.1 RCStoVCS)
  • mto: This revision was merged to the branch mainline in revision 4860.
  • Revision ID: ian.clatworthy@canonical.com-20091203232116-f8igfvc6muqrn4yx
Revision Control -> Version Control in docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
# Written by Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
17
17
 
18
18
"""Bzrlib specific gzip tunings. We plan to feed these to the upstream gzip."""
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
20
from cStringIO import StringIO
23
21
 
24
22
# make GzipFile faster:
29
27
import zlib
30
28
 
31
29
# we want a \n preserved, break on \n only splitlines.
32
 
from bzrlib import symbol_versioning
 
30
import bzrlib
33
31
 
34
32
__all__ = ["GzipFile", "bytes_to_gzip"]
35
33
 
120
118
    Yes, its only 1.6 seconds, but they add up.
121
119
    """
122
120
 
123
 
    def __init__(self, *args, **kwargs):
124
 
        symbol_versioning.warn(
125
 
            symbol_versioning.deprecated_in((2, 3, 0))
126
 
            % 'bzrlib.tuned_gzip.GzipFile',
127
 
            DeprecationWarning, stacklevel=2)
128
 
        gzip.GzipFile.__init__(self, *args, **kwargs)
129
 
 
130
121
    def _add_read_data(self, data):
131
122
        # 4169 calls in 183
132
123
        # temp var for len(data) and switch to +='s.
404
395
        # (4 seconds to 1 seconds for the sample upgrades I was testing).
405
396
        self.write(''.join(lines))
406
397
 
407
 
    if sys.version_info > (2, 7):
408
 
        # As of Python 2.7 the crc32 must be positive when close is called
409
 
        def close(self):
410
 
            if self.fileobj is None:
411
 
                return
412
 
            if self.mode == gzip.WRITE:
413
 
                self.crc &= 0xFFFFFFFFL
414
 
            gzip.GzipFile.close(self)
415
398