[Zope-Coders] Re: [Zope-dev] Unicode treatment in 2.6b1

Guido van Rossum guido@python.org
Mon, 30 Sep 2002 10:08:46 -0400


> In the original (pre-python 2.0) implementation this restriction was
> needed because of the needs of plain/unicode string comparisons. The
> default encoding affects how cross-type comparisons perform. It
> therefore needs to affects the hash value of strings, and hash
> values are required to be consistent within the lifetime of one
> program so that, for example, dictionaries can be efficient.
> 
> In those early days sys.setdefaultencoding was needed because there
> was some debate about what the default encoding should be. (Guido
> originally favoured utf8). The original idea was that this funtcion
> was to be removed before the release of 2.0, once a global decision
> had been made. Im not sure why that didnt happen.

Because it can be a useful feature (for some sites) to be able to
change the default encoding permanently during initialization, before
any non-ASCII strings are created, without needing to recompile
Python.

But if you're using this at any other time, you're playing with fire
and I can't guarantee that Python will work correctly.

--Guido van Rossum (home page: http://www.python.org/~guido/)