chunking a long string?

Chris Angelico rosuav at gmail.com
Fri Nov 8 15:53:10 EST 2013


On Sat, Nov 9, 2013 at 7:43 AM,  <wxjmfauth at gmail.com> wrote:
> Oops, sorry, I'm wrong, it can be much more.
>
>>>> sys.getsizeof('ab')
> 27
>>>> sys.getsizeof('a\U0001d11e')
> 48
>>>>

I know, overhead sucks doesn't it. Python is really abysmal at that;
look how big a single bit is:

>>> sys.getsizeof(1)
14
>>> sys.getsizeof(True)
14

On the flip side, Python gets really awesome at some other things.
Your operating system probably takes an entire CD to distribute, maybe
even a DVD, so that's either 700MB or 4.7GB, give or take. Look how
efficiently Python can represent it:

>>> sys.getsizeof(os)
36

Wow!

ChrisA



More information about the Python-list mailing list