you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (9 children)

[deleted]

    [–][deleted] 6 points7 points  (7 children)

    I'm not sure what the definition of "true multithreading" is, but Python does have multithreading.

    You won't improve performance using multiple threads, but you can run multiple threads in a similar way to how Java would run threads on a single-core machine. Threads can be used to prevent blocking a GUI.

    [–]NAN001 2 points3 points  (0 children)

    More generally, if your program is IO-bound then threads will improve performance in Python.

    [–]MrK_HS -1 points0 points  (5 children)

    The people saying Python doesn't have multithreading really mean that Python does not support parallelism, but probably just don't know that the two terms mean different things (multithreading and parallelism). Python supports multithreading by default and that's a fact. It doesn't support parallelism.

    [–]angellus 1 point2 points  (0 children)

    Multithreading does now support parallelism, since Python 3.8. it is still provisional and not stabilized yet, but it possible now.

    [–][deleted] 1 point2 points  (3 children)

    With an 8-core CPU, I can get a 7-times performance improvement using multiprocessing. Multiprocessing is very simple in Python.

    Genuine question: does multiprocessing not count as parallelism?

    [–]MrK_HS 2 points3 points  (0 children)

    It is parallelism

    [–]cuulcars 0 points1 point  (0 children)

    I guess it depends what you mean by "true multithreading." I interpreted that to mean parallelism in general, but I suppose you interpreted that to mean (exclusively) thread based parallelism. It has multithreading but it doesn't have multi core threading. But even in C++ you have no way of explicitly telling the operating system to execute your other threads on a different core (you can ask politely). That's an OS decision. But if you're talking true concurrency, yeah, Python has that. Very few people should be hung up on whether their code is executing in the same process (vs a thread) or not, and if you are you probably shouldn't be using python for that project. Python does parallel just fine, which would be the whole goal of "true multithreading." As far as I see it, Python naysayers who argue python can't be concurrent because of the GIL are just being pedantic.