[Python-Dev] Python 3.x and bytes

Guido van Rossum guido at python.org
Thu May 19 19:46:14 CEST 2011

On Thu, May 19, 2011 at 10:50 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Last thought I have for a possible 'solution' -- when a bytes object is
> tested for equality against an int raise TypeError.  Precedent being sum()
> raising a TypeError when passed a list of strings because performance is so
> poor.  Reason here being that the intuitive behavior will never work and
> will always produce silent bugs.

Not the same thing at all. The == operator is special, and should not
raise exceptions; too many things would start randomly failing (e.g.
membership tests for a dict that has both ints and bytes as keys, or
for a list containing a variety of types).

--Guido van Rossum (python.org/~guido)

More information about the Python-Dev mailing list