[Python-3000] struni and the Apple four-character-codes

Guido van Rossum guido at python.org
Fri Jul 27 07:07:52 CEST 2007


On 7/26/07, Jeffrey Yasskin <jyasskin at gmail.com> wrote:
> I've sent the patch as http://python.org/sf/1761465 using Guido's
> suggestion of using bytes, but I do philosophically prefer Talin's and
> Ronald's suggestions.

I've checked in what you submitted; at this point I take whatever I
can get if it makes unit tests pass. :-)

I'm not so sure that the "philosophically optimal" solution is all
that practical. After all we could have done that before, but we
didn't -- we used strings, because that's the most convenient way to
spell them in Python code, and (nearly) all APIs that take or return
these are C code which can do whatever it wants.

We could use Unicode strings where in the past we used 8-bit strings,
but that would be somewhat nasty when there's ever one of these codes
that's not pure ASCII -- we'd have to worry about encoding them
properly. So I'm happy with byte strings and the occasional helper to
convert these to strings or ints when using them as keys. (Personally
I'd like to use strings for the keys since {'TEXT': 'stuff'} is a lot
clearer than {1413830740: 'stuff'} when encountered in a debugging
session.)

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


More information about the Python-3000 mailing list