On Mon, Feb 9, 2009 at 10:28 PM, oyster <lepto.pyt...@gmail.com> wrote: > I mean this > [code] > def fib(n): > if n<=1: > return 1 > return fib(n-1)+fib(n-2) > > useCore(1) > timeit(fib(500)) #this show 20 seconds > > useCore(2) > timeit(fib(500)) #this show 10 seconds > [/code] > > Is it possible? > > and more, can threads/multi-processors/clusters be used to improve fib?
Considering the GIL, I highly doubt it so. Also, the algorithm is fundamentally linear -- each result depends on previous results -- so I don't think you can easily parallelize it (if at all). You'd probably get greater speedup using memoization. Cheers, Chris -- Follow the path of the Iguana... http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list