DataSize: define __slot__
For small classes, like this one, with known attributes, using dict
wastes a lot of RAM. Defining __slots__ as a list will save a lot of
memory, while improving the performance a bit.
Before this patch:
>>> timeit.timeit('data_structures.DataSize("1M").b',
setup='from avocado.utils import data_structures',
number=1000000)
>>> 1.1383171081542969
After this patch:
>>> timeit.timeit('data_structures.DataSize("1M").b',
setup='from avocado.utils import data_structures',
number=1000000)
>>> 1.1071600914001465
Signed-off-by: NAmador Pahim <apahim@redhat.com>
Showing
想要评论请 注册 或 登录