Pyhon 2.x or 3.x, which is faster?

Steven D'Aprano steve at pearwood.info
Wed Mar 9 10:38:41 EST 2016


On Thu, 10 Mar 2016 02:06 am, Jon Ribbens wrote:

> On 2016-03-09, Steven D'Aprano <steve at pearwood.info> wrote:
>> generate the output. Without seeing the code you used, I have *no idea*
>> how you could get that result. If you read the file in binary, you should
>> get this:
>>
>> b'\xef\xbb\xbf\xe2\x82\xac\xe2\x82\xac\xe2\x82\xac'
>>
>> Or in decimal:
>>
>> 239, 187, 191, 226, 130, 172, 226, 130, 172, 226, 130, 172
>>
>> How you are getting 8218 instead of 130, I have no idea!
> 
> Decode as "windows-1252".

Nicely done!


py> b'\xef\xbb\xbf\xe2\x82\xac\xe2\x82\xac\xe2\x82\xac'.decode('cp1252')
'€€€'
py> [ord(c) for c in _]
[239, 187, 191, 226, 8218, 172, 226, 8218, 172, 226, 8218, 172]



-- 
Steven




More information about the Python-list mailing list