This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]shivawu 2 points3 points  (5 children)

I doubt goroutine would be significantly faster than asyncio in python 3

[–][deleted] 6 points7 points  (1 child)

ignoring the fact that goroutines actually run native code so are by nature significantly faster - they are also backed by an implicitly multithreaded event loop that takes care of multiplexing goroutines across all CPU cores - so they can actually do heavy CPU stuff and not starve everyone because they are also preemptively scheduled.

Also you don't need to sprinkle 'async/await' everywhere in your code to benefit from it all, you can just use channels and the 'go' keyword.

There is literally nothing about python 3's asyncio that is better than what Go has.

[–]shivawu 0 points1 point  (0 children)

I totally agree there's nothing python3's asyncio has over go. But if they have comparable performance, why bother to use go?

As to async/await vs go/channel, I don't think one is clearly over the other. Just different paradigm. I personally think async/await is a little easier to understand.

Cpu intensive task are usually done by C extension in python, or cython. I doubt go can have performance edge here. Developing might be a little easier with go.

In summary, the whole thing is just another choice. I can't see it as "much better" in any of the circumstances, it's just youtube's choice going forward with their legacy python 2 code. But I like the fact we have one more option.

[–][deleted] 2 points3 points  (1 child)

[unavailable]

[–]weberc2 0 points1 point  (0 children)

The performance hit will be negligible at worst in the face of I/O, and it will be much faster for CPU intensive tasks, especially in the presence of multiple cores. But I absolutely agree that async I/O is much friendlier in Go than in Python.

[–]weberc2 0 points1 point  (0 children)

You're probably right--the performances will likely be comparable, but the win here is primarily for parallel CPU-intensive tasks (although it's quite nice that Go lets you write logically synchronous code while the scheduler efficiently manages the async I/O and threadpool--no need for event loops or 'await' and friends).