• anton@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    5 days ago

    Now do computation in those threads and realize that they all wait on the GIL giving you single core performance on computation and multi threaded performance on io.

    • AndrasKrigare@beehaw.org
      link
      fedilink
      arrow-up
      4
      ·
      5 days ago

      Correct, which is why before I had said

      I think OP is making a joke about python’s GIL, which makes it so even if you are explicitly multi threading, only one thread is ever running at a time, which can defeat the point in some circumstances.

      • thisisnotgoingwell@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        5 days ago

        Isn’t that what threading is? Concurrency always happens on single core. Parallelism is when separate threads are running on different cores. Either way, while the post is meant to be humorous, understanding the difference is what prevents people from picking up the topic. It’s really not difficult. Most reasons to bypass the GIL are IO bound, meaning using threading is perfectly fine. If things ran on multiple cores by default it would be a nightmare with race conditions.

        • AndrasKrigare@beehaw.org
          link
          fedilink
          arrow-up
          1
          ·
          4 days ago

          I haven’t heard of that being what threading is, but that threading is about shared resourcing and memory space and not any special relationship with the scheduler.

          Per the wiki:

          On a multiprocessor or multi-core system, multiple threads can execute in parallel, with every processor or core executing a separate thread simultaneously; on a processor or core with hardware threads, separate software threads can also be executed concurrently by separate hardware threads.

          https://en.m.wikipedia.org/wiki/Thread_(computing)

          I also think you might be misunderstanding the relationship between concurrency and parallelism; they are not mutually exclusive. Something can be concurrent through parallelism, as the wiki page has (emphasis mine):

          Concurrency refers to the ability of a system to execute multiple tasks through simultaneous execution or time-sharing (context switching), sharing resources and managing interactions.

          https://en.m.wikipedia.org/wiki/Concurrency_(computer_science)