You are viewing a single comment's thread from:

RE: Daily Steem-Python Challenge #19, Win 1 Steem!

in #programming6 years ago

Nice work! I will send you the prize money.

Question:

You create a separate dict for each thread:
results.append({})

And you also lock this dict for every write:

      lock.acquire()
            if operation not in self.stats:
                self.stats[operation] = 1
            else:
                self.stats[operation] += 1
            lock.release()

Is this required since the dict is still part of the results list? I do not know, so this is a genuine question.

My solution is a bit different in that regard and also yields faster times, I will be submitting a tutorial soon.

Sort:  

Yeah, I don't think that lock is necessary. I used it because I thought since they are all part of a larger array I should use it to be safe, but I think it would be just as safe without. Nice catch!

Coin Marketplace

STEEM 0.17
TRX 0.12
JST 0.028
BTC 55508.70
ETH 2914.45
USDT 1.00
SBD 2.30