Solved by ptrblck in post #2 
              
              
                I think iterating the dict would be the right approach. If you are concerned about the performance of this loop, you could use a dict comprehension, which could yield a speedup, but I would recommend to profile the code first and check, if this loop is indeed the bottleneck in your code.