News for hackers. Stuff that matters.
Re:What's up, Python? The GIL removed, a new compiler, optpa... by chlorion on Sunday July 30, 2023 @10:10PM (#36938102)
You have to be much more careful about what you modify when using multithreading, so I'm not sure what you mean by that.

A lot of people here mention that sharing data is much easier with multithreading, but doing this without races is not easy.

You can't just use the values from difference threads like you would in normal code, you need to synchronize access with locks, which can be difficult to do correctly and can harm performance in a lot of cases.

I think a lot of the people who complain about the GIL are going to become acutely aware of why it was useful when they attempt to use GIL-less multithreading, and realize that removing it wasn't as great as it sounded at first!

In my experience, most problems are inherently synchronous with lots of mutable state and complex data dependencies, or inherently parallel with lots of tasks that can run independently. Problems that can be easily parallelized already work fine with multiprocessing! Problems that can't be easily parallelized are not something you can just slap some threading on to get more performance, and will require a lot of work to keep state synced!

This is just my opinion though and I'm sure there are plenty of domains that I don't have experience with that will benefit from no-GIL python!

Re:What's up, Python? The GIL removed, a new compiler, optpa... by thrashh on Sunday July 30, 2023 @10:27PM (#36938182)
Multithreading is hard but once you have been doing it a while, it becomes easy and most importantly, it’s stable.

When you have to deal with processes, there’s a lot of external factors out of your control because processes are much more visible and carry a lot of extra baggage.

Hard multithreading problems are fun. Hard multi-process problems are just tedious.

Re:What's up, Python? The GIL removed, a new compiler, optpa... by da39a3ee on Monday July 31, 2023 @08:59AM (#36941908)
As I understand it on Linux processes and threads are implemented in almost the same way, just that threads share memory. I've heard it said several times that the idea that processes are "heavier" is a bit of a myth. I guess they need to allocate heap space and threads don't. I'm not an expert, just mentioning because it sounded like you might be believing something which is at odds with what people say about processes and threads on Linux.
Re:What's up, Python? The GIL removed, a new compiler, optpa... by chlorion on Tuesday August 01, 2023 @10:21PM (#36966200)
I'm not a Linux kernel dev but I think this is true! Not sure what's up with the downvotes.

You can create a process/thread chimera with certain system calls, and get something that is in-between a thread and process if you want, which is neat but maybe not that useful.

Creating processes on Linux is actually much faster than people seem to realize. I can spawn at least a few thousand a second from a quick test of spawning bash instances.

Re:What's up, Python? The GIL removed, a new compiler, optpa... by imtringued on Monday July 31, 2023 @02:31AM (#36939428)
>I think a lot of the people who complain about the GIL are going to become acutely aware of why it was useful when they attempt to use GIL-less multithreading, and realize that removing it wasn't as great as it sounded at first!

There is no such thing as "GIL-less multithreading. The GIL does not do what you think it does. It does not synchronize your multithreaded code at all. It only synchronizes code that was single threaded to begin with.

Also... Your argument about locking being harmful to performance while arguing in favour of a global lock makes you look like a novice who has less than a month of software development experience.

Re:What's up, Python? The GIL removed, a new compiler, optpa... by ghshephard on Monday July 31, 2023 @03:34AM (#36939723)
https://news.ycombinator.com/newsguidelines.html

> Be kind. Don't be snarky. Converse curiously; don't cross-examine. Edit out swipes.

> When disagreeing, please reply to the argument instead of calling names. "That is idiotic; 1 + 1 is 2, not 3" can be shortened to "1 + 1 is 2, not 3."

Re:What's up, Python? The GIL removed, a new compiler, optpa... by dang on Monday July 31, 2023 @03:58AM (#36939864)
I don't mean to pile on to what ghshephard already posted, but I'm afraid you've been breaking the site guidelines repeatedly lately - not just here but these:

https://news.ycombinator.com/item?id=36923922

https://news.ycombinator.com/item?id=36921060

... as well as others. Can you please not do this? We're trying for something different here. If you wouldn't mind reviewing https://news.ycombinator.com/newsguidelines.html and taking the intended spirit of the site more to heart, we'd be grateful.

Re:What's up, Python? The GIL removed, a new compiler, optpa... by mvncleaninst on Monday July 31, 2023 @04:09AM (#36939932)
> Problems that can be easily parallelized already work fine with multiprocessing!

Yeah, except afaik you pay more in context switches, sharing is more cumbersome. Also language runtime of a single process is likely working with less information, you end up using more memory on multiple language runtime instances

Frankly I'd just use Java or Go at that point and not even bother

Re:What's up, Python? The GIL removed, a new compiler, optpa... by alfalfasprout on Monday July 31, 2023 @12:43PM (#36945284)
Not sure why this is directed at my comment-- I didn't touch on synchronization.

Yes, locks like mutexes, semaphores, etc. and approaches like atomics, lockfree datastructures come into play when writing multithreaded code. There's no getting around that.

> In my experience, most problems are inherently synchronous with lots of mutable state and complex data dependencies, or inherently parallel with lots of tasks that can run independently. Problems that can be easily parallelized already work fine with multiprocessing!

This is a hot take though-- most problems that are truly embarrassingly parallel don't work as well as you'd think w/ multiprocessing. There's a ton of overhead there and when you do need synchronization steps (eg; in reductions) it can get pretty messy.