How to use two threads (GUI and backend)
jmp
jeanmichel at sequans.com
Thu Oct 27 09:14:19 EDT 2016
On 10/27/2016 02:55 PM, Chris Angelico wrote:
> On Thu, Oct 27, 2016 at 11:33 PM, jmp <jeanmichel at sequans.com> wrote:
>> On 10/27/2016 01:43 PM, Chris Angelico wrote:
>>>
>>> Blocked threads don't consume CPU time. Why would they?
>>>
>>> ChrisA
>>>
>>
>> Agreed. My point being that a blocked thread achieve nothing, except
>> parallelism, i.e. other threads can be processed.
>>
>> To be more specific, if you compute factorial(51354) in a thread, it will
>> still require approx. the same amount of CPU clocks than in a main thread
>> (probably slightly more due to the scheduler overhead).
>>
>> jm
>
> Of course. But the OP wants to do blocking calls, which don't cost you
> like that. So it's fine.
>
> ChrisA
Sure but the OP is very focus on performance(that's a mistake imo).
"Because I don't want to drop python, I want to learn the best technique
to use to have the best performance. "
I just wanted to point that using thread implements parallelism, not
performance. And that's probably what its gui needs. And that's probably
why using a higher level API would have been acceptable.
JM
Best performance is achieved by sacrificing a lot in python. A better
technique than polling threads would be sleeping thread where the thread
is put to hold until a hardware interrupt wakes up the thread.
More information about the Python-list
mailing list