[Python-Dev] [comp.lang.python] sys.setdefaultencoding (2.0b1)
Sat, 16 Sep 2000 20:19:59 +0200
Guido van Rossum wrote:
> > I was just reading comp.lang.python and saw an interesting question
> > that I couldn't answer. Is anyone here game?
> >From reading the source code for unicodeobject.c, _PyUnicode_Init()
> sets the default to "ascii" anyway, to the call in site.py is quite
> unnecessary. I think it's a good idea to remove it. (Look around
> though -- there are some "if 0:" blocks that could make it necessary.
> Maybe the setdefaultencoding() call should be inside an "if 0:" block
> too. With a comment.
Agreed. I'll fix this next week.
Some background: the first codec lookup done causes the encodings
package to be loaded which then registers the encodings package
codec search function. Then the 'ascii' codec is looked up
via the codec registry. All this takes time and should only
be done in case the code really uses codecs... (at least that
was the idea).
> --Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)
> > Jeremy
> > ------- Start of forwarded message -------
> > From: Donn Cave <firstname.lastname@example.org>
> > Newsgroups: comp.lang.python
> > Subject: sys.setdefaultencoding (2.0b1)
> > Date: 12 Sep 2000 22:11:31 GMT
> > Organization: University of Washington
> > Message-ID: <email@example.com>
> > Mime-Version: 1.0
> > Content-Type: text/plain; charset=ISO-8859-1
> > I see codecs.c has gone to some trouble to defer character encoding
> > setup until it's actually required for something, but it's required
> > rather early in the process anyway when site.py calls
> > sys.setdefaultencoding("ascii")
> > If I strike that line from site.py, startup time goes down by about
> > a third.
> > Is that too simple a fix? Does setdefaultencoding("ascii") do something
> > important?
> > Donn Cave, firstname.lastname@example.org
> > ------- End of forwarded message -------
> > _______________________________________________
> > Python-Dev mailing list
> > Python-Dev@python.org
> > http://www.python.org/mailman/listinfo/python-dev
> Python-Dev mailing list
Python Pages: http://www.lemburg.com/python/