no, they’re just saying python is slow. even without the GIL python is not multithreaded. the thread library doesn’t use OS threads so even a free-threaded runtime running “parallel” code is limited to one thread.
If what you said were true, wouldn’t it make a lot more sense for OP to be making a joke about how even if the source includes multi threading, all his extra cores are wasted? And make your original comment suggesting a coding issue instead of a language issue pretty misleading?
But what you said is not correct. I just did a dumb little test
And then ps -efT | grep python and sure enough that python process has 4 threads. If you want to be even more certain of it you can strace -e clone,clone3 python ./threadtest.py and see that it is making clone3 syscalls.
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.
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.
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.
no, they’re just saying python is slow. even without the GIL python is not multithreaded. the
thread
library doesn’t use OS threads so even a free-threaded runtime running “parallel” code is limited to one thread.If what you said were true, wouldn’t it make a lot more sense for OP to be making a joke about how even if the source includes multi threading, all his extra cores are wasted? And make your original comment suggesting a coding issue instead of a language issue pretty misleading?
But what you said is not correct. I just did a dumb little test
import threading import time def task(name): time.sleep(600) t1 = threading.Thread(target=task, args=("1",)) t2 = threading.Thread(target=task, args=("2",)) t3 = threading.Thread(target=task, args=("3",)) t1.start() t2.start() t3.start()
And then
ps -efT | grep python
and sure enough that python process has 4 threads. If you want to be even more certain of it you canstrace -e clone,clone3 python ./threadtest.py
and see that it is makingclone3
syscalls.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.
Correct, which is why before I had said
Ups, my attention got trapped by the code and I didn’t properly read the comment.
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.
is this stackless?
anyway, that’s interesting! i was under the impression that they eschewed os threads because of the gil. i’ve learned something.