unicode() vs. s.decode()

Michael Ströder michael at stroeder.com
Thu Aug 6 21:25:03 EDT 2009


Thorsten Kampe wrote:
> * Michael Ströder (Thu, 06 Aug 2009 18:26:09 +0200)
>>>>> timeit.Timer("unicode('äöüÄÖÜß','utf-8')").timeit(10000000)
>> 17.23644495010376
>>>>> timeit.Timer("'äöüÄÖÜß'.decode('utf8')").timeit(10000000)
>> 72.087096929550171
>>
>> That is significant! So the winner is:
>>
>> unicode('äöüÄÖÜß','utf-8')
> 
> Unless you are planning to write a loop that decodes "äöüÄÖÜß" one 
> million times, these benchmarks are meaningless.

Well, I can tell you I would not have posted this here and checked it if it
would be meaningless for me. You don't have to read and answer this thread if
it's meaningless to you.

Ciao, Michael.



More information about the Python-list mailing list