Finding size of Variable

wxjmfauth at gmail.com wxjmfauth at gmail.com
Thu Feb 6 14:51:54 CET 2014


Le jeudi 6 février 2014 12:10:08 UTC+1, Ned Batchelder a écrit :
> On 2/6/14 5:15 AM, wxjmfauth at gmail.com wrote:
> 
> 
> 
> >>>>
> 
> >>>> sum([sys.getsizeof(c) for c in ['a', 'a EURO', 'aa EURO']*3])
> 
> > 336
> 
> >>>> sum([sys.getsizeof(c) for c in ['aa EURO aa EURO']*3])
> 
> > 150
> 
> >>>> sum([sys.getsizeof(c.encode('utf-32')) for c in ['a', 'a EURO', 'aa EURO']*3])
> 
> > 261
> 
> >>>> sum([sys.getsizeof(c.encode('utf-32')) for c in ['aa EURO aa EURO']*3])
> 
> > 135
> 
> >>>>
> 
> >
> 
> > jmf
> 
> >
> 
> 
> 
> JMF, we've told you I-don't-know-how-many-times to stop this. 
> 
> Seriously: think hard about what your purpose is in sending these absurd 
> 
> benchmarks.  I guarantee you are not accomplishing it.
> 
> 
> 
> -- 
> 
> Ned Batchelder, http://nedbatchelder.com

Sorry, I'm only pointing you may lose memory when
working with short strings as it was explained.
I really, very really, do not see what is absurd
or obsure in:

>>> sys.getsizeof('abc' + 'EURO')
46
>>> sys.getsizeof(('abc' + 'EURO').encode('utf-32'))
37

I apologize for the " a EURO" which should have
been a real "EURO". No idea, what's happend.

jmf




More information about the Python-list mailing list