classification
Title: Superfluous import in cgi module
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: ezio.melotti, mjholtkamp, python-dev
Priority: normal Keywords: easy, patch

Created on 2012-12-24 12:53 by mjholtkamp, last changed 2012-12-25 13:14 by mjholtkamp. This issue is now closed.

Files
File name Uploaded Description Edit
patch-python2.7-cgi.py.diff mjholtkamp, 2012-12-24 13:04 Patch against 2.7 cgi.py
Messages (6)
msg178055 - (view) Author: Michiel Holtkamp (mjholtkamp) Date: 2012-12-24 12:53
The standard module cgi.py from Python 2.x imports urllib, but urllib is not used. This causes a little bit of extra memory usage and a small increase in load time. It's not much, but it was enough for me to notice when I was profiling my program.

I think the urllib import can be safely removed in 2.6 and 2.7. I've tested without the import and it works as expected in my case.

In Python 3.2 (other 3.x versions not checked), urllib.parse is imported but here it is actually used, so no problem there.

PS. first time submitting a bug here, so if I'm doing something wrong, please be gentle :)
msg178056 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-12-24 12:58
Python 2.6/3.1 only get security fixes, and 2.7/3.2/3.3 only get bug fixes.
This is technically a performance issue, so I'm not sure it can go in 2.7, but if the change is as simple as it seems it could be considered.
msg178057 - (view) Author: Michiel Holtkamp (mjholtkamp) Date: 2012-12-24 13:04
Fair enough, I think I'm using 2.7 only. I wasn't sure about the patch format, so I added a unified diff. If you require a different format, please let me know.
msg178119 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-25 12:27
New changeset f77648af7ff0 by Ezio Melotti in branch '2.7':
#16765: remove unused import.
http://hg.python.org/cpython/rev/f77648af7ff0
msg178120 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-12-25 12:29
Fixed, thanks for the report!

> I wasn't sure about the patch format, so I added a unified diff.

The best way is to get a clone of CPython and use "hg diff > patch.diff".  You can find more information about it in the devguide.
msg178125 - (view) Author: Michiel Holtkamp (mjholtkamp) Date: 2012-12-25 13:14
Thanks, I will do that next time. Happy holidays everyone!
History
Date User Action Args
2012-12-25 13:14:47mjholtkampsetmessages: + msg178125
2012-12-25 12:29:45ezio.melottisetstatus: open -> closed
messages: + msg178120

assignee: ezio.melotti
resolution: fixed
stage: needs patch -> resolved
2012-12-25 12:27:42python-devsetnosy: + python-dev
messages: + msg178119
2012-12-24 13:04:51mjholtkampsetfiles: + patch-python2.7-cgi.py.diff
keywords: + patch
messages: + msg178057
2012-12-24 12:58:18ezio.melottisetversions: - Python 2.6
nosy: + ezio.melotti

messages: + msg178056

keywords: + easy
stage: needs patch
2012-12-24 12:53:37mjholtkampcreate