unicode() vs. s.decode()
michael at stroeder.com
Sun Aug 9 01:42:14 CEST 2009
Michael Fötsch wrote:
> If speed is your primary concern, this will give you even better
> performance than unicode():
> decoder = codecs.lookup("utf-8").decode
> for i in xrange(1000000):
Hmm, that could be interesting. I will give it a try.
> However, there's also a functional difference between unicode() and
> unicode() always raises an exception when you try to decode a unicode
> object. str.decode() will first try to encode a unicode object using the
> default encoding (usually "ascii"), which might or might not work.
Thanks for pointing that out. So in my case I'd consider that also a plus for
More information about the Python-list