classification
Title: range usage in gzip module leads to excessive memory usage.
Type: resource usage Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: cjw296 Nosy List: cjw296, ezio.melotti, jcea, nadeem.vawda, python-dev
Priority: normal Keywords: patch

Created on 2012-11-08 15:26 by cjw296, last changed 2012-11-13 05:12 by ezio.melotti. This issue is now closed.

Files
File name Uploaded Description Edit
gzip.py.patch cjw296, 2012-11-08 16:55 review
Messages (7)
msg175176 - (view) Author: Chris Withers (cjw296) * (Python committer) Date: 2012-11-08 15:26
gzip.py uses range instead of xrange in two places.
This results in excessive memory usage when opening large .gz files.
I actually bumped into this using tarfile.

Am I right in thinking that range basically *is* xrange in 3.x? If so, this bug applies only to 2.6 and 2.7.
msg175181 - (view) Author: Jesús Cea Avión (jcea) * (Python committer) Date: 2012-11-08 16:14
Yes, "range()" in python 3 is equivalent to python 2 "xrange()".

2.6 is in "security only" fix mode. So, you only need to fix 2.7.
msg175184 - (view) Author: Chris Withers (cjw296) * (Python committer) Date: 2012-11-08 16:55
Okay, here's the patch.
I can't imagine any unit tests are needed or will be impacted by this.

I do have commit rights, am I good to commit this?
msg175186 - (view) Author: Nadeem Vawda (nadeem.vawda) * (Python committer) Date: 2012-11-08 19:21
Looks good to me. Go ahead.

You needn't add or change any tests for this, but you should run the
existing tests before committing, just to be safe.
msg175195 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-08 22:07
Also remember to add a Misc/NEWS entry (and/or run `make patchcheck`) before committing.  If this only affects 2.7 there's no need to merge anything with 3.x, so you can just commit on 2.7 and push.
msg175243 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-09 15:54
New changeset f938d478359a by Chris Withers in branch '2.7':
Bug #16441: avoid excessive memory usage working with large gzip files
http://hg.python.org/cpython/rev/f938d478359a
msg175245 - (view) Author: Chris Withers (cjw296) * (Python committer) Date: 2012-11-09 15:59
Committed on 2.7 branch.
History
Date User Action Args
2012-11-13 05:12:09ezio.melottisetresolution: fixed
2012-11-09 15:59:44cjw296setstatus: open -> closed

messages: + msg175245
stage: patch review -> resolved
2012-11-09 15:54:54python-devsetnosy: + python-dev
messages: + msg175243
2012-11-08 22:07:32ezio.melottisetnosy: + ezio.melotti
messages: + msg175195
2012-11-08 19:21:01nadeem.vawdasetnosy: + nadeem.vawda
messages: + msg175186
2012-11-08 16:55:06cjw296setfiles: + gzip.py.patch
keywords: + patch
messages: + msg175184

stage: needs patch -> patch review
2012-11-08 16:17:58jceasetversions: - Python 2.6
2012-11-08 16:14:17jceasetnosy: + jcea
messages: + msg175181
2012-11-08 15:26:23cjw296create