Assigned memory is not disproportionate; you create 100,000 objects! As you can see, they occupy approximately 34 megabytes of space:
>>> sys.getsizeof(Test())+sys.getsizeof(Test().__dict__)
344
>>> (sys.getsizeof(Test())+sys.getsizeof(Test().__dict__)) * 1000000 / 10**6
34.4
You can get a little improvement with __slots__, but you still need about 20 MB of memory to store these 100,000 objects.
>>> sys.getsizeof(Test2())+sys.getsizeof(Test2().__slots__)
200
>>> sys.getsizeof(Test2())+sys.getsizeof(Test2().__slots__) * 1000000 / 10**6
20.0
( mensi answer, sys.getsizeof . , .)
. SO: __slots__?
http://docs.python.org/release/2.5.2/ref/slots.html
__slots__:
class Test2():
__slots__ = ['a','b','c','d','e']
def __init__(self):
...