String changing size on failure?

David Beazley dave at dabeaz.com
Wed Nov 1 16:32:00 EDT 2017


Nah. I discuss this behavior (caching of UTF-8 conversions in the C API) in section 15.14 of the Python Cookbook. The tweet was a tutorial, not a question ;-). Admittedly, an evil tutorial...
Cheers,
Dave
> On Nov 1, 2017, at 2:53 PM, Skip Montanaro <skip.montanaro at gmail.com> wrote:
>> Leave it to DB to ask the tough questions other people won't. :-)
>> Skip
>>> On Wed, Nov 1, 2017 at 2:26 PM, Ned Batchelder <ned at nedbatchelder.com> wrote:
>> From David Beazley (https://twitter.com/dabeaz/status/925787482515533830):
>>>>>>> a = 'n'
>>>>> b = 'ñ'
>>>>> sys.getsizeof(a)
>> 50
>>>>> sys.getsizeof(b)
>> 74
>>>>> float(b)
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> ValueError: could not convert string to float: 'ñ'
>>>>> sys.getsizeof(b)
>> 77
>>>> Huh?
>>>> --Ned.
>>>> --
>> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /