Py 3.3, unicode / upper()

Ian Kelly ian.g.kelly at gmail.com
Wed Dec 19 22:31:42 CET 2012


On Wed, Dec 19, 2012 at 2:18 PM,  <wxjmfauth at gmail.com> wrote:
> latin-1 (iso-8859-1) ? are you sure ?

Yes.

>>>> sys.getsizeof('a')
> 26
>>>> sys.getsizeof('ab')
> 27
>>>> sys.getsizeof('aé')
> 39

Compare to:

>>> sys.getsizeof('a\u0100')
42

The reason for the difference you posted is that pure ASCII strings
have a further optimization, which I glossed over and which is purely
a savings in overhead:

>>> sys.getsizeof('abcde') - sys.getsizeof('a')
4
>>> sys.getsizeof('ábçdê') - sys.getsizeof('á')
4



More information about the Python-list mailing list