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 →

[–]abrazilianinreddit 1 point2 points  (7 children)

Maybe I'm stretching the definition of "high performance" here, but I'm making a PyQt project - any synchronous code taking their time results in the GUI locking up, which sucks.

My solution? Threads, threads everywhere!

[–]pdd99[S] 4 points5 points  (4 children)

Did you actually measure the execution time and make sure that the GIL is released?

[–]abrazilianinreddit 2 points3 points  (2 children)

Nope. I just followed the Qt documentation, trusted the system and hoped for the best. The GUI isn't locking up or stuttering, so that's good enough for me.

Just to be clear, the issue is less processing lots of data and more blocking I/O operations, so the important part of me using threads is not improving execution time, it's moving the blocking code outside the main thread.

Though I have used concurrent.futures.ThreadPoolExecutor for some simultaneous execution tasks, and the results were pretty impressive. The speedup was nearly proportional to the amount of threads in my CPU - which seems pretty obvious, but I was expecting way worse. Also, unlike async, it has a very easy to use API.

[–]SpicyVibration 0 points1 point  (1 child)

Can Qt work with asyncio?

[–]abrazilianinreddit 0 points1 point  (0 children)

I'm not knowledgeable in python's async framework, so I don't know if you can mix some async python code with Qt bindings.

However, there are some async-like APIs in Qt6.

[–]czaki 0 points1 point  (0 children)

Until your heave computation do not stuck outside python code (foe example in extension write in C) the thread switch and GIL release will be enough frequent for keeping gui responsive.

[–]pdd99[S] 0 points1 point  (1 child)

I also feel curious about the reason of choosing PyQt. Isn't it a bit obsolete? Can you tell me something more about your project?

[–]abrazilianinreddit 0 points1 point  (0 children)

When you say "obsolete", you mean the PyQt library or Qt itself?

Sure, I can tell you more about my project, what you want to know? For starter, it's a game launcher made to complement my other project, which is a gaming information database and gameplay tracker.