[issue28508] Need way to expose incremental size of key sharing dicts

2016-10-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: >>> from sys import getsizeof >>> class A: def __init__(self, a, b, c, d, e, f): self.a = a self.b = b self.c = c self.d = d self.e = e self.f = f

[issue28508] Need way to expose incremental size of key sharing dicts

2016-10-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Hmm, seems no dict here is shared-key dict. Yes. That seems to be the case. Apparently, doing an update() to the inst dict cause it to recombine. -- resolution: -> not a bug status: open -> closed ___

[issue28508] Need way to expose incremental size of key sharing dicts

2016-10-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Hmm, seems no dict here is shared-key dict. -- ___ Python tracker ___ ___

[issue28508] Need way to expose incremental size of key sharing dicts

2016-10-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Isn't this already implemented? No. >>> class A: pass >>> d = dict.fromkeys('abcdefghi') >>> a = A() >>> a.__dict__.update(d) >>> b = A() >>> b.__dict__.update(d) >>> import sys >>> [sys.getsizeof(m) for m in

[issue28508] Need way to expose incremental size of key sharing dicts

2016-10-22 Thread Xiang Zhang
Xiang Zhang added the comment: > Isn't this already implemented? Get the same question. dict.__sizeof__ can identify shared dicts. -- nosy: +xiang.zhang ___ Python tracker

[issue28508] Need way to expose incremental size of key sharing dicts

2016-10-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: >>> class C: ... def __init__(self): ... for i in range(682): ... setattr(self, 'a%d'%i, None) ... >>> sys.getsizeof(C().__dict__) / len(C().__dict__) 4.058651026392962 -- ___ Python

[issue28508] Need way to expose incremental size of key sharing dicts

2016-10-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Isn't this already implemented? -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue28508] Need way to expose incremental size of key sharing dicts

2016-10-22 Thread Raymond Hettinger
New submission from Raymond Hettinger: In many Python programs much of the memory utilization is due to having many instances of the same object. We have key-sharing dicts that reduce the cost by storing only in the incremental values. It would be nice to have visibility to the savings.