Alan Isaac <[EMAIL PROTECTED]> writes:
> Here is one way: > > - for each fund, create a ``reportreceived`` dict that maps stocks to > booleans (initially False) > - as each stock notifies its funds, the fund changes False to True and checks > ``all(reportreceived.values())`` to determine whether it is ok to notify > investors. > - When it is ok, the fund notifies investors and resets all the > ``reportreceived`` values. > > Is this sensible enough? What are standard and better ways? You could explore the performance of popping items from the dict/set, instead of toggling the value so to true. Once the dict is empty, you are done. Of course the dict/set would be called stocks_that_havent_reported, or a saner & shorter variant of that. The idea here is that checking a dict/set for emptiness is close-to-zero time operation. -- http://mail.python.org/mailman/listinfo/python-list