3 ms·
If you generate a lot of goroutines, the overhead for maintaining and scheduling them is fairly significant, particularly when compared to constructs like Pytho
by falcolas 13y ago
If you generate a lot of goroutines, the overhead for maintaining and scheduling them is fairly significant, particularly when compared to constructs like Python generators.
I've demonstrated this myself by comparing the goroutines example prime number generator to a similar version written using Python generators.
The python generator code was faster, but there was a hard limit to how many primes could be calculated this way; I hit the stack limit.
[Edit] Code & times: http://pastebin.com/CqkMcxdK http://pastebin.com/CqkMcxdK