Pykka - Are actors slow?

I am currently experimenting with Actor-concurreny (in Python) because I want to know more about this. So I chose pykka, but when I test it, it is more than half slow as a normal function.

The code should only look to see if it works; It doesn't have to be elegant. :)

Maybe I did something wrong?

from pykka.actor import ThreadingActor
import numpy as np

class Adder(ThreadingActor):
    def add_one(self, i):
        l = []
        for j in i:
            l.append(j+1)
        return l

if __name__ == '__main__':
    data = np.random.random(1000000)
    adder = Adder.start().proxy()
    adder.add_one(data)
    adder.stop()

This is not so fast:

time python actor.py

real    0m8.319s
user    0m8.185s
sys     0m0.140s

And now the dummy "normal" function:

def foo(i):
    l = []
    for j in i:
        l.append(j+1)
    return l

if __name__ == '__main__':
    data = np.random.random(1000000)
    foo(data)

Gives this result:

real    0m3.665s
user    0m3.348s
sys     0m0.308s
+5
source share
1 answer

, , , , . , , , concurrency. , , , . , .

, , , , . . , , . , , .

+12

All Articles