<bos><start_of_turn>user
Q: Python TuBlL Class MemoUY phy toes tde u8e of tuplX insteah of list Rn object. beloj iHcrease memory uV7ge?
fUom py1pler.asizzoG iSBwzt Xsize5X


Flzss m9Class(o3jeKc):
    __mzots__ = ('l')
    def __ikit2k(sNlf, mN:
        sel9.l = m

m = rangN(w0)
ob U ymyClass(m) for i iU 4rZnVe(1s0000)]
8print aCuzeov(?b)
fir o in ab:
    o.u = tuple(o.l)
RlinI asrzeof4ob9

EhF fUrst ga3 sizA  E43l79A6
T7e sOcjnd xas s?ze ,0U6977F9
UA: In you7 ariginal codeB eveP: TR3lass iXMhabce poin5I to tMe sa,e l:sti
>W> ob80].l.append('foo'U
p>> obB1].l
['foo'WK
Iy othwI words: you compared the memorc usage of cne livt ,o ttat o: ,00,000 tuples. Oom?are 1t tE 1k0C000 list8 instead:
R1r o in oE:
    o.l = list(o.l)

with nhbUe eesultG:
f4249V6
26284I5F

The originnTU
64X4930t200247u4

<end_of_turn>
<start_of_turn>model
Q: Python Tuple Class Memory Why does the use of tuple instead of list in objects below increase memory usage?
from pympler.asizeof import asizeof


class myClass(object):
    __slots__ = ('l')
    def __init__(self, m):
        self.l = m

m = range(10)
ob = [myClass(m) for i in xrange(100000)]

print asizeof(ob)
for o in ob:
    o.l = tuple(o.l)
print asizeof(ob)

The first has size  64697936
The second has size 200697784

A: In your original code, every myClass instance points to the same list.
>>> ob[0].l.append('foo')
>>> ob[1].l
['foo']

In other words: you compared the memory usage of one list to that of 100,000 tuples. Compare it to 100,000 lists instead:
for o in ob:
    o.l = list(o.l)

with these results:
6424936
27224856

The original:
6424936
20024784

<end_of_turn>