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.

Author kxroberto
Recipients
Date 2006-05-09.15:59:48
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
This superseeds the old patch #1053150 (for an older
Python; it was stopped: "Jeremy doesn't like the idea")
in order to import the expensive modules behind urllib2
late.

I'm recommending now again to do this, as things are
almost unacceptable meanwhile.

In Py24, simply importing original urllib2 costs upto
to a second on my slower machines. the startup time of
some of my bigger apps/scripts goes mainly to importing
urllib2. More than half of the time goes into importing
cookielib (regarding profiler runs). Its almost
unusable so now in CGI scripts.

New modules were added to urllib2 meanwhile, and worst
of all the cookielib was inserted into urllib2 the same
old style "import everything on top of the file in a
kind of C-#include manner". 

Python offers best dynamic modularization of code. That
should be exploited for such an expensive
virtualization module like urllib2. There are usually
only very locations, where the sub-modules are referenced. 
This patch also enables to strip off unnecessary
modules (down to _MozillaCookieJar!) for
cx_freeze/py2exe distribution. 

( Since long I have this patch on my list, which I
apply after each Python installation regularly. )

--

As a side effect of this import-all practice a lazy
cookielib dependency came into normal Request
constructor code:
"origin_req_host = cookielib.request_host(self)"

I'd recommend, to copy/move this simple tool function
request_host into urllib2 in order to resolve the
cookielib dependency completely. (not done so far in
the patch)



-robert






History
Date User Action Args
2007-08-23 15:48:49adminlinkissue1484793 messages
2007-08-23 15:48:49admincreate