DataSize: simplify __init__
Instead of using regex to parse the `data`, let's use a simpler and more
performatic version witch just handles the last character to figure out
the unit.
Before this patch:
>>> timeit.timeit('data_structures.DataSize("1M").b',
setup='from avocado.utils import data_structures',
number=1000000)
>>> 2.988218069076538
After this patch:
>>> timeit.timeit('data_structures.DataSize("1M").b',
setup='from avocado.utils import data_structures',
number=1000000)
>>> 2.0695440769195557
Signed-off-by: NAmador Pahim <apahim@redhat.com>
Showing
想要评论请 注册 或 登录