[Tutor] How python keeps track of objects
Dave Angel
davea at davea.name
Sun Nov 23 21:26:06 CET 2014
On 11/23/2014 01:05 PM, Mitch Raful wrote:
> On Sun, Nov 23, 2014 at 11:07 AM, Dave Angel <davea at davea.name> wrote:
>> Please don't top-post. Trim the quoted portion to the parts you're
>> responding to, and put your response immediately after (each) section you're
>> commenting on.
>>
> I this the correct formatting and in plain text?
Excellent. Thanks for listening.
>>
>> Once you launch a second thread, you have to worry about when it's done
>> updating the corresponding item in objects. So somewhere you probably want
>> a wait() call.
>>
>
> Would a t0.join() work instead of a wait call?
That's what I meant. Sorry about the typo.
Note that sometimes we don't want to join() a thread, we just reuse it
for the next operation. That can gain efficiency at the cost of more
confusing program flow. Somebody has to keep track of which operations
are still pending, which are in process, and which have been completed.
Example, suppose you had a list of 500 items. You might usefully spawn
10 threads, then reuse those threads till there are no more "objects" to
process. And since some operations would go quicker than others, you
might not want to hardwire 5 per thread.
--
DaveA
More information about the Tutor
mailing list