Python vs C++

wxjmfauth at gmail.com wxjmfauth at gmail.com
Sat Aug 23 06:00:31 EDT 2014


Le vendredi 22 août 2014 23:38:56 UTC+2, Michael Torrie a écrit :
> [...]
> Go is
> 
> quite young but promising except that unicode is all UTF-8 byte strings,
> 
> so string operations are going to be a bit slow.


Certainly not (mathematics).

>>> # Py 3.4.0
>>> timeit.timeit("(s1*100 + s2)[:-1]", "s1 = 'hundred'; s2 = 'EURO'")
1.9532454724939043
>>> timeit.timeit("(s1*100 + s2)[:-3]", "s1 = 'hundred'.encode('utf-8');\
...     s2 = 'EURO'.encode('utf-8')")
0.982759184290785


There are however valid reasons to not use utf-8. It
is not really direcly tied to the intrisic coding
of the characters, but to linguistics and scriptings.

jmf



More information about the Python-list mailing list