omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Bypassing the GIL.

    Pythonista
    4
    9
    5522
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • chibill
      chibill last edited by chibill

      In this topic I am going to be documenting my advantures trying to bypass the GIL using Apple's threading api and objc_utils. I also want to develop it into basically a multiprocessing API for pythonista.

      Firstly some docs.
      https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Multithreading/Introduction/Introduction.html That is on just Multithreading.

      I may end up using the Dispatch query.
      https://developer.apple.com/library/ios/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html

      1 Reply Last reply Reply Quote 1
      • chibill
        chibill last edited by

        Okay so far jaunt using NSThread will not help. As it still obeys the GIL.

        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by JonB

          what's your end goal? i.e what situation do you see benefitting from gil bypass? there are some specific ios background tools like for downloading files which hand over the downloading task to the os.

          it seems to me that anything involving objc executing python code still trampolines code back into the interpreter, so won't help you. In the beta 3 you might have luck running a program in each interpreter -i'd assume each interpreter has a seperate GIL.

          1 Reply Last reply Reply Quote 0
          • chibill
            chibill last edited by

            I am trying to get something like normal multiprocessing in Python. I was thinking reading could work with objc because I have had things from objc code I can before the script that still was running while a new script was running.

            1 Reply Last reply Reply Quote 0
            • dgelessus
              dgelessus last edited by

              I think bypassing the GIL completely is not possible - after all, all the code you can write on Pythonista needs to be run by the Python interpreter. Even if you have multipe threads from Objective-C, to execute Python code a thread still needs to hold the GIL, which logically only one thread can do at a time.

              1 Reply Last reply Reply Quote 0
              • chibill
                chibill last edited by

                You are probably right. but I can still try.

                1 Reply Last reply Reply Quote 0
                • JonB
                  JonB last edited by

                  If the goal is to "run multiple programs at once", Threads work fine. For instance stash does this well (you can "background" commands using &, etc).

                  Certain things, like numpy calls, the gil is released while numpy is executing a c call (and numpy is linked with the Accelerate framework, so theoretically should be using multiple cores for certain types of operations).
                  Certain bits of the ui are just thin wrappers on objc, so most of the ui handling is done outside of python. You can run two or more ui's , and since mostly the ui is handling user interaction, and then calling back to python, using Threads or ui.delay, etc for long running tasks ensures that things stay responsive

                  Rather than try to figure out how to bypass the gil, which probably cannot be done in a generic way, focus on what you would do if you could.... their may be some native frameworks, etc that let you accomplish the same goals.

                  1 Reply Last reply Reply Quote 0
                  • ccc
                    ccc last edited by

                    https://github.com/larryhastings/gilectomy ;-)

                    1 Reply Last reply Reply Quote 0
                    • ccc
                      ccc last edited by

                      https://morepypy.blogspot.ch/2017/08/lets-remove-global-interpreter-lock.html

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB Forums | Contributors