Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is from the decimal benchmarks included in the python source[1], in the recipe given in the decimal documentation[2] the precision is increased for the intermediate steps of the algorithm so it gives the correct end result.

  >>> pi()
  Decimal('3.141592653589793238')
1. http://hg.python.org/cpython/file/344d67063c8f/Modules/_deci...

2. http://docs.python.org/library/decimal.html#recipes



Thank you, out of interest on a appliction I work on every now and then showed a 50% improvement with the code as is, not heavy decimal at all, mostly int's though still a nice speedup.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: