pjmlp 3 days ago

My mistake, as I assumed they took the same decision as jython and IronPython.

https://jython.readthedocs.io/en/latest/Concurrency/#no-glob...

https://wiki.python.org/moin/IronPython

The difference between JVM, CLR and C in regards to parallel and concurrent code is that they are built for those kind of workloads, and have a memory model proper, hence not needing a GIL.

  • commodoreboxer 2 days ago

    I think they would have to here, to support native modules. Jython (and I believe IronPython, but don't quote me) does not support native CPython modules. CPython modules explicitly control the GIL, so if they are supported (as they are here), you can't really leave the GIL out without exposing potential thread safety issues.

westurner 3 days ago

"PEP 703 – Making the Global Interpreter Lock Optional in CPython" (2023) https://peps.python.org/pep-0703/

CPython built with --disable-gil does not have a GIL (as long as PYTHONGIL=0 and all loaded C extensions are built for --disable-gil mode) https://peps.python.org/pep-0703/#py-mod-gil-slot

"Intent to approve PEP 703: making the GIL optional" (2023) https://news.ycombinator.com/item?id=36913328#36917709 https://news.ycombinator.com/item?id=36913328#36921625

  • kaashif 3 days ago

    This is pretty beside the point. The point is that X not having a GIL doesn't inherently mean Python on X also doesn't have a GIL.

    • westurner 2 days ago

      CPython does not have a GIL Global Interpreter Lock GC Garbage Collection phase with --gil-disabled. GraalVM does have a GIL, like CPython without --gil-disabled.

      How CPython accomplished nogil in their - the original and reference - fork is described in the topical linked PEP 703.

      • kaashif 2 days ago

        Yes, I know. What I'm saying is that:

        It's possible to have a language that doesn't have a GIL, which you implement Python in, but that Python implementation then has a GIL.

        The point being that you can't say things like: Jython is written in Java so it doesn't have a GIL. CPython is written in C so doesn't have a GIL. And so on.

        If this isn't clear, I apologize.

        • westurner 2 days ago

          Oh okay. Yeah I would say that the Java GC and the ported CPython GIL are probably limits to the performance of any Python in Java implementation.

          But are there even nogil builds of CPython C extensions on PyPi yet anyway.

          Re: Ghidraal and various methods of Python in Java: https://news.ycombinator.com/item?id=36454485