This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Superfluous import in cgi module
Type: performance Stage: resolved
Components: Library (Lib) Versions: Python 2.7
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 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit mjholtkamp, 2012-12-24 13:04 Patch against 2.7
Messages (6)
msg178055 - (view) Author: Michiel Holtkamp (mjholtkamp) Date: 2012-12-24 12:53
The standard module 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.
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!
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60969
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: +
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