Deutsch English Français Italiano |
<v0ovis$1uq6q$3@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: Threads across programming languages Date: Mon, 29 Apr 2024 13:22:52 -0700 Organization: A noiseless patient Spider Lines: 37 Message-ID: <v0ovis$1uq6q$3@dont-email.me> References: <GIL-20240429161553@ram.dialup.fu-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 29 Apr 2024 22:22:53 +0200 (CEST) Injection-Info: dont-email.me; posting-host="68a1f8b2290ba520f984bb7e7fb4eebe"; logging-data="2058458"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Dtk+hhrF6s6fofpcDNe2Qi6VxTX8jPvc=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:/dmXvYQ7g3ir/++zDueA7tkdpCI= Content-Language: en-US In-Reply-To: <GIL-20240429161553@ram.dialup.fu-berlin.de> Bytes: 2847 On 4/29/2024 8:19 AM, Stefan Ram wrote: > paavo512 <paavo@osa.pri.ee> wrote or quoted: > |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 true > 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 there > 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. [...] Have you ever used webworkers?