Python 3
Stephen J. Turnbull
stephen at xemacs.org
Wed Jun 23 06:11:14 BST 2010
Andrew Bennetts writes:
> The change to bytes and unicode handling seems like something that
> will be difficult to support in 2.5 and 3.x from the same code base
> without a performance hit, because b"" literals were only added in
> 2.6.
I think the _b() device should handle literals. If the 2.x compiler
doesn't already optimize _b('Andrew') to 'Andrew', some sort of
preprocessing step would be ugly but not impossible, or a monkey patch
to the compiler.
The issue that worries me (as is being discussed in a different
context on python-dev) is that some modules in the stdlib now expect
to be passed str = unicode instead of str = bytes. To the extent that
such a module is on the critical path, you could take a big
performance hit there, or face the need to rewrite some of the stdlib
to provide a parallel bytes API.
OTOH, this would only affect Python 3, and you have plenty of time to
wait for or design performance improvements there. N.B. Guido has
expressed support for "polymorphism", which he defines to mean that
functions which process strings (bytes or unicode) return the type fed
to them (and error on inconsistency). I don't know if that applies to
Python 3.2, though (FLUFL, WDYT?)
More information about the bazaar
mailing list