[Python-Dev] bytes.from_hex()

Stephen J. Turnbull stephen at xemacs.org
Sun Feb 26 17:05:51 CET 2006

>>>>> "Greg" == Greg Ewing <greg.ewing at canterbury.ac.nz> writes:

    Greg> I think we need some concrete use cases to talk about if
    Greg> we're to get any further with this. Do you have any such use
    Greg> cases in mind?

I gave you one, MIME processing in email, and a concrete bug that is
possible with the design you propose, but not in mine.  You said, "the
programmers need to try harder."  If that's an acceptable answer, I
have to concede it beats all any use case I can imagine.

I think it's your turn.  Give me a use case where it matters
practically that the output of the base64 codec be Python unicode
characters rather than 8-bit ASCII characters.

I don't think you can.  Everything you have written so far is based on
defending your maintained assumption that because Python implements
text processing via the unicode type, everything that is described as
a "character" must be coerced to that type.

If you give up that assumption, you get

1.  an automatic reduction in base64.upcase() bugs because it's a type
    error, ie, binary objects are not text objects, no matter what their

2.  encouragement to programmer teams to carry along binary objects as
    opaque blobs until they're just about to put them on the wire,
    then let the wire protocol guy implement the conversion at that point

3.  efficiency for a very common case where ASCII octets are the wire

4.  efficient and clear implementation and documentation using the
    codec framework and API

I don't really see a downside, except for the occasional double
conversion ASCII -> unicode -> UTF-16, as is allowed (but not
mandated) in XML's use of base64.  What downside do you see?

School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.

More information about the Python-Dev mailing list