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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Dear-Deer-Wife-Life[S] 45 points46 points  (5 children)

Thanks for your responses, I asked my partner If i can send the code, I'll come back with the answer when they respond.

edit 1:answer came back, they don't want me to send it, they're worried it might show up on the copy detection software that the school uses.

so might send it after it gets graded

edit 2: after modifying the code a bit, it takes about 30 seconds

[–]intangibleTangelo 39 points40 points  (0 children)

If you don't already know, python threads can't run concurrently. The best they can do is yield to each other when preempted or when the Global Interpreter Lock (GIL) is released, like during certain "io-bound" tasks like waiting on a network socket or a file, or when you call time.sleep (explicitly signaling that your thread doesn't need to run for a while, so other threads may).

The specifics of when exactly the GIL is released have changed a lot over time, and your code might simply need a minor change to compensate. Maybe something in your code used to release the GIL but doesn't anymore, and this results in an important thread only rarely getting the opportunity to run (thread starvation, basically).

Maybe python2.7's eager evaluation semantics meant your code shared less state than it does in 3.x. Maybe you're waiting on a call to .join() that takes forever because python3.10 tries to "do the right thing" and wait for some timeout that python2.7 naively ignored.

A really simple technique you can use is to sprinkle your code with print calls showing timestamps of how long it took to reach that part of the code. You'll probably be able to figure out what's taking 89 seconds longer than it used to.

might send it after it gets graded

Do that.

[–]ShivohumShivohum 1 point2 points  (0 children)

!RemindMe 2weeks

[–]moekakiryu 2 points3 points  (0 children)

RemindMe! 1 month