Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on What’s New In Python 3.6. Parent comment
>>> import collections >>> import sys >>> class A: ... def __init__(self, x, y): ... self.x = x ... self.y = y ... >>> class B: ... __slots__ = ('x', 'y') ... def __init__(self, x, y): ... self.x = x ... self.y = y ... >>> C = collections.namedtuple('C', ('x', 'y')) >>> a = A(1, 1) >>> b = B(1, 1) >>> c = C(1, 1) >>> d = {'x': 1, 'y': 1} >>> sys.getsizeof(a) + sys.getsizeof(a.__dict__) # Plain object 344 >>> sys.getsizeof(b) + sys.getsizeof(b.__slots__) # Plain object with slots 120 >>> sys.getsizeof(c) # Named Tuple 64 >>> sys.getsizeof(d) # Dict 288
EDIT2: Included size of __slots__ tuple
https://docs.python.org/3/library/tracemalloc.html
EDIT2: Included size of __slots__ tuple