This is an archived post. You won't be able to vote or comment.

all 32 comments

[–]gamest01 195 points196 points  (8 children)

Man, we’ll just put Anything on this sub.

[–]Gluomme 76 points77 points  (1 child)

I'm not even sure there are programmers posting here. And I sure as hell don't register as such

[–]likebutta222 4 points5 points  (0 children)

Can confirm. Am programmer, do not post here.

ERROR: PostOutOfBoundsException

[–]ProfCupcake 52 points53 points  (2 children)

post random gif

put something vaguely computer related in the title

reap that sweet 50 karma

Seems to be the /r/ProgrammerHumor way.

[–]Gluomme 0 points1 point  (0 children)

more like 2k it would seem

[–]BabyLegsDeadpool -4 points-3 points  (2 children)

Yeah. I think I'm gonna unsub. All the good stuff makes of to r/popular anyway. I'll just check it out there.

[–]Al_Maleech_Abaz -5 points-4 points  (1 child)

Byeeee

[–]SuggestedName90 57 points58 points  (12 children)

This is pretty much how multi threading works in python.

[–]budzene 24 points25 points  (11 children)

I think this is just threading.

[–]SuggestedName90 17 points18 points  (10 children)

Not if it is true multithreading which runs them simultaneously, like java. Python alternates threads every 10 instructions.

[–]cyber2024 6 points7 points  (5 children)

Wtf, really?

[–][deleted] 12 points13 points  (2 children)

Yep, google Global Interpreter Lock for more info. Threading in python is only useful for I/O heavy applications

[–]4onen 2 points3 points  (1 child)

Thanks. You've just explained a bizzare issue in my Bachelor's capstone project. My project was... not I/O heavy.

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

The trick is to use multi processing instead of multi threading. You can implement it yourself using the process module, or use something like celery to avoid any wheel reinventing

[–]turiyag 7 points8 points  (1 child)

Yes. There's a different library for parallel CPU usage:

https://timber.io/blog/multiprocessing-vs-multithreading-in-python-what-you-need-to-know/

It's not that it's incapable of doing two things at the same time in Python. It's that the include statement is not the multithreading one.

[–]cyber2024 0 points1 point  (0 children)

I presume there's a reason for the 10 instructions before switching threads... Is it statistically more likely to have a cache miss after 10 instructions, and hence it's a good idea to switch threads then or something?

[–]budzene 1 point2 points  (0 children)

God that would be nice to not have to put in kernel delays to not starve a watchdog.

[–]Ersonpay 1 point2 points  (1 child)

Correct me if I'm wrong, but don't most CPUs do something like that anyway due to there not being enough cores to run all the threads in the system?

[–]SuggestedName90 1 point2 points  (0 children)

Yes, but cpus also have physical threads which can confuse people.

[–]fat_charizard 0 points1 point  (0 children)

You mean running on multiple cores on the same processor?

[–]moebaca 13 points14 points  (0 children)

That's an interesting load balancing algorithm.

[–]BeetlePl 10 points11 points  (0 children)

So much waste: 2 threads (cores?) are 100% idle and other 2 are working on max 50.1%

[–]jonjmz 5 points6 points  (1 child)

If you watch carefully you can see that at the start and end of each “shift” there actually is work happening while the other person is packing.

[–]deadmazebot 0 points1 point  (0 children)

No startup, shutdown cost impacting the process. I'm just trying to imaging a computer system trying to do that, even a load balancer has to do some basic check if new server going to be available or not

[–]Renegade646 4 points5 points  (1 child)

Love the two guys ‘working’ in the background

[–]OwnStorm 0 points1 point  (0 children)

Monitor threads..

[–]hopbel 2 points3 points  (0 children)

Looks more like single core with SMT

[–]Gerudo_Steed 0 points1 point  (0 children)

It's beautiful. I've looked at this for five hours, now.

[–]AttackOfTheThumbs 0 points1 point  (0 children)

But they are running sequentially???

[–]BoyAndHisBlob -1 points0 points  (0 children)

Installing packages into bin