|
Very good question! Python have a couple of tools to handle concurrency and parallelism, but it's a mess. For I/O bound programs, you can use threading (in stdlib).
For CPU bound, you can use multiprocessing (also in stdlib).
But these have huge overhead, (e.g starting a Python thread costs 32kb memory minimum.) and there are multiple solutions in the stdlib like ThreadPoolExecutor and ProcessPoolExecutor in concurrent.futures beside the threading and multiprocessing modules... If you want to write async code, there is tornado with callbacks, tornado with the new async stuff, asyncio (tulip for Python2), the new async/await from 3.5 which is very immature. The async part of the ecosystem is like a totally separate whole new world, you can't really mix and match or pick parts from the other, however, there are brave folks like Andrew Godwin how tries to make Django async with not moderate success. For web frameworks, there are a ton of servers which might fit you, but they are mostly very complex to set up or reason about like greenlets, pre-forked web servers and stuff. I have 5 years experience with Python, using it every day and once I tried to write a custom SSH server and it took 1-2 weeks to grasp Tornado fully, then I tried the same with Go and WITH LEARNING THE LANGUAGE itself, it took me about 2 weekends and my server was up and running! TL;DR: You can write concurrent code with Python but it's a mess and you will probably have a hard time. |