3 ms·
Python allows for memory sharing between threads - which is why a GIL is necessary. A high-level language with a strict shared-nothing concurrency model doesn'
by 15155 1y ago
Python allows for memory sharing between threads - which is why a GIL is necessary.
A high-level language with a strict shared-nothing concurrency model doesn't need a GIL... but you naturally can't practically share very large objects between BEAM processes.
- icedchai 1y agoIf you couldn’t share memory between threads, they’d be called something else. Many languages have threading without a GIL.
- innocentoldguy 1y agoHi, 15155. May I clarify a couple of things? 1. Regarding Python's GIL: The issue isn't memory sharing between threads. Java and Go allow you to do this, too, but they don't have GILs. The reason Python has a GIL is that it uses reference counting for memory management. If it didn't have a GIL, multiple threads could simultaneously manipulate reference counts, which would lead to memory corruption/leaks. 2. You can share massive "objects" between BEAM processes. For example, if you're running BEAM in a 64-bit environment, you can share maps, structs, and other data structures that are up to 2,305,843,009,213,693,951 bytes in size. I hope this information helps. I also hope it is correct. I think it is, but I've been wrong before.
- pjmlp 1y ago1. not really, you can do this with atomic operations, which is now what CPython does, since GIL removal got final.
- pjmlp 1y agoOnly on CPython, other implementations never had one, and it is finally gone on CPython 3.14.