Finding size of Variable

Neil Cerutti neilc at norwich.edu
Tue Feb 11 15:29:22 CET 2014


On 2014-02-10, Ned Batchelder <ned at nedbatchelder.com> wrote:
> On 2/10/14 9:43 AM, Tim Chase wrote:
>>> The opposite of what the utf8/utf16 do!
>>>
>>>>>> sys.getsizeof(('a' * 1000000 + 'oe' +
>>>>>> '\U00010000').encode('utf-8'))
>>> 1000023
>>>>>> sys.getsizeof(('a' * 1000000 + 'oe' +
>>>>>> '\U00010000').encode('utf-16'))
>>> 2000025
>>
>> However, as pointed out repeatedly, string-indexing in
>> fixed-width encodings are O(1) while indexing into
>> variable-width encodings (e.g. UTF8/UTF16) are O(N).  The FSR
>> gives the benefits of O(1) indexing while saving space when a
>> string doesn't need to use a full 32-bit width.
>
> Please don't engage in this debate with JMF.  His mind is made
> up, and he will not be swayed, no matter how persuasive and
> reasonable your arguments.  Just ignore him.

I think reasonable criticisms should be contested no matter who
posts them. I agree jmf shouldn't be singled out for abuse,
summoned, insulted, or have his few controversial opinions
brought into other topics. Tim's post was responding to a
specific, well-presented criticism of Python's string
implementation. Left unchallenged, it might linger unhappily in
the air, like a symphony ended on a dominant 7th chord.

-- 
Neil Cerutti




More information about the Python-list mailing list