can multi-core improve single funciton?

oyster lepto.python at gmail.com
Tue Feb 10 01:28:15 EST 2009


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?

thanx



More information about the Python-list mailing list