En Wed, 18 Feb 2009 23:36:25 -0200, sturlamolden <sturlamol...@yahoo.no>
escribió:
On Feb 10, 7:28 am, oyster <lepto.pyt...@gmail.com> wrote:

Let's rewrite that slightly and see...

def fib(n, _map=None):
    if not _map: _map = map
    if n > 2:
        return sum(_map(fib, (n-1, n-2)))
    else:
        return 1


With two cores:

E:\>python fibotest.py
parallel t: 31.300226 seconds
sequential t: 48.070695 seconds


Yes it can!

Are you kidding?
This is like building a house one brick at a time, but before placing a
new brick, you throw all the previous work and start again from start.
Certainly two workers would help more than one - but the best way to do it
is *NOT* to repeat all that additional work over and over in the first
place.
Even my Pentium I MMX 233MHz can compute fib(36) thousand of times faster
than that with the right algorithm. So I don't see the point in
parallelizing if you're going to get infinitely worse results...

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to