Caching for speed is a concept brand new to me, and there's a remarkable example in a thread on the python-list. I thought some readers of this list might find it instructive. However, to run the scripts you'll need mpmath. < http://code.google.com/p/mpmath/>

Begin by jumping in toward the end of the thread:

< http://mail.python.org/pipermail/python-list/2007-November/466662.html >

Note Fredrik Johansson's function f() that he suggests could greatly speed up my demo of the amazing Chudnovsky algorithm for pi, at < http://python.pastebin.com/f4410f3dc>.

I didn't understand what to do with it, so I ask, < http://mail.python.org/pipermail/python-list/2007-November/467148.html >. But see the revision I did make, < http://py77.python.pastebin.com/f48e4151c>

And his revision of that, < http://py77.python.pastebin.com/m6b2b34b7>.

As for the speed-up on my computer due to the caching done by f(): < http://py77.python.pastebin.com/f48e4151c> takes 151 secs for 2000 digits of pi; < http://py77.python.pastebin.com/m6b2b34b7> takes 0.4 secs!

Dick Moores
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to