title: Is there a faster alternative to python's Decimal?
body: <p>Does anyone know of a faster decimal implementation in python?</p>
  
  <p>As the example below demonstrates, the standard library's decimal module is ~100 times slower than <code>float</code>.</p>
  
  <pre class="lang-py prettyprint-override"><code>from  timeit import Timer
  
  def run(val, the_class):
      test = the_class(1)
      for c in xrange(10000):
          d = the_class(val)
          d + test
          d - test
          d * test
          d / test
          d ** test
          str(d)
          abs(d)    
  
  if __name__ == "__main__":
      a = Timer("run(123.345, float)", "from decimal_benchmark import run")
      print "FLOAT", a.timeit(1)
      a = Timer("run('123.345', Decimal)", "from decimal_benchmark import run; from decimal import Decimal")
      print "DECIMAL", a.timeit(1)
  </code></pre>
  
  <p><em>Outputs:</em></p>
  
  <pre><code>FLOAT 0.040635041427
  DECIMAL 3.39666790146
  </code></pre>