[Python-Dev] Strange error importing a Pickle from 2.7 to 3.2
M.-A. Lemburg
mal at egenix.com
Wed Feb 23 22:54:34 CET 2011
Alexander Belopolsky wrote:
> On Wed, Feb 23, 2011 at 4:23 PM, M.-A. Lemburg <mal at egenix.com> wrote:
> ..
>> "Latin-1" is the official name and the one used internally by Python,
>> so it would be good to have the test suite and Python code in general
>> to use that variant of the name (just as "utf-8" is preferred over
>> "utf8").
>>
>> Instead of adding more aliases to the C code, please change the
>> encoding names in the stdlib and test suite.
>
> I cannot agree with you on this one. Official or not, "latin-1" is
> much less commonly used than "latin1". Currently decode("latin1") is
> 10x slower than decode("latin-1") on short strings. We already have
> a check for "iso-8859-1" alias in PyUnicode_AsEncodedString(). Adding
> "latin1" (and possibly "utf8" as well) is likely to speed up many
> applications at minimal cost.
Fair enough, then add "latin1" and "utf8" to both PyUnicode_Decode()
and PyUnicode_AsEncodedString().
Still, the stdlib and test suite should be examples of using the
correct names.
I only found these few cases where the wrong Latin-1 name is used
in the stdlib:
./distutils/command/bdist_wininst.py:
-- # convert back to bytes. "latin1" simply avoids any possible
-- encoding="latin1") as script:
-- script_data = script.read().encode("latin1")
./urllib/request.py:
-- data = base64.decodebytes(data.encode('ascii')).decode('latin1')
./asynchat.py:
-- encoding = 'latin1'
./ftplib.py:
-- encoding = "latin1"
./sre_parse.py:
-- encode = lambda x: x.encode('latin1')
I get 12 hits for the test suite.
Yet 108 for the correct name, so I can't follow your statement
that the wrong variant is used more often.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Feb 23 2011)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
More information about the Python-Dev
mailing list