Skip to content

Comment on Python 3.3.0 released

Comments

"•A C implementation of the "decimal" module, with up to 80x speedup for decimal-heavy applications"

That in itself is should make a few python gamers happy. Also some serious motivations for older version users, not all but more and more. Also many other interesting develepments others have highlighted already.

And 80x is apparently actually an understatement, at least for a few cases. Some numbers recently posted to python-dev show up to a 124X improvement:

  Precision: 9 decimal digits

  float:
  result: 3.1415926535897927
  time: 0.113188s

  cdecimal:
  result: 3.14159265
  time: 0.158313s

  decimal:
  result: 3.14159265
  time: 18.671457s


  Precision: 19 decimal digits

  float:
  result: 3.1415926535897927
  time: 0.112874s

  cdecimal:
  result: 3.141592653589793236
  time: 0.348100s

  decimal:
  result: 3.141592653589793236
  time: 43.241220s

Impressive stuff, though what struck me was the results, least accuracy wise and what rounding they using:

Pi is 3.14159 26535 89793 238....

So I do wonder what rounding they are using, even truncating as I have (next digit 4 so good place to do that) then can see the last digit should at least be 8, worst case 7 and 6!! There again this may be a convention or result of the methord to calulate Pi.

As for floats, well, for accuracy I'd go with cdecimal right there, though is it as accurate. I suspect it is the formular used that induces the minute error in results.

http://en.wikipedia.org/wiki/Pi #21 reference

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.

Gamers? Why are they heavy users of the decimal module?

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.