On Wed, Apr 3, 2013 at 1:53 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > (sys.getsizeof(s) - sys.getsizeof(''))/len(s)
>>> s = '\x80\x81\x82\x83\x84\x85' >>> len(s) 6 >>> import sys >>> sys.getsizeof(s) 43 >>> sys.getsizeof(s) - sys.getsizeof('') 18 >>> (sys.getsizeof(s) - sys.getsizeof('')) / len(s) 3.0 I didn't know there was a 3-byte-width representation. :-) More seriously, it fails because '' is ASCII and s is not, and the overhead for the two strings is different. -- http://mail.python.org/mailman/listinfo/python-list