Liste des Groupes | Revenir à cl c |
paavo512 <paavo@osa.pri.ee> wrote or quoted:In C++, async io is provided e.g. by the asio library.
|Anyway, multithreading performance is a non-issue for Python so far as
|the Python interpreter runs in a single-threaded regime anyway, under a
|global GIL lock. They are planning to get rid of GIL, but this work is
|still in development AFAIK. I'm sure it will take years to stabilize the
|whole Python zoo without GIL.
The GIL only prevents multiple Python statements from being
interpreted simultaneously, but if you're waiting on inputs (like
sockets), it's not active, so that could be distributed across
multiple cores.
With asyncio, however, you can easily handle the application
for threads to "wait in parallel" for thousands of sockets in a
single thread, and there are fewer opportunities for errors than
with multithreading.
Additionally, there are libraries like numpy that use trueHuh, my goal is to avoid Python, not to work with it. Unfortunately this (avoiding Python) becomes harder all the time.
multithreading internally to distribute computational tasks
across multiple cores. By using such libraries, you can take
advantage of that. (Not to mention the AI libraries that have their
work done in highly parallel fashion by graphics cards.)
If you want real threads, you could probably work with Cython
sometimes.
Other languages like JavaScript seem to have an advantage thereBeen there, done that, worked through it ... 15 years ago. Nowadays non-trivial multi-threaded parallel processing in C++ seems pretty easy for me, one just needs to follow some principles and take care to get the details correct. I guess it's about the same as memory management in C, one can get it correct with taking some care. In C++ I can forget about memory management as it is largely automatic, but for multithreading I still need to take care.
because they don't know a GIL, but with JavaScript, for example,
it's because it always runs in a single thread overall. And in
the languages where there are threads without a GIL, you quickly
realize that programming correct non-trivial programs with
parallel processing is error-prone.
Les messages affichés proviennent d'usenet.