mardi 18 avril 2017

Python Tuple Class Memory

Why does the use of tuple instead of list in objects below increase memory usage?

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)






Comments
0 Comments

0 commentaires:

Enregistrer un commentaire