is there faster choice python's decimal?
does anyone know faster decimal doing python?
as instance next demonstrates, customary library's decimal way ~100 times slower float.
from timeit import timer
def run(val, the_class):
exam = the_class(1)
c xrange(10000):
d = the_class(val)
d + test
d - test
d * test
d / test
d ** test
str(d)
abs(d)
if __name__ == "__main__":
= timer("run(123.345, float)", "from decimal_benchmark import run")
imitation "float", a.timeit(1)
= timer("run('123.345', decimal)", "from decimal_benchmark import run; decimal import decimal")
imitation "decimal", a.timeit(1)
outputs:
float 0.040635041427
decimal 3.39666790146
Comments
Post a Comment