I think this loop could be done analogously to the new logic in the coach report api_views. Loop over all logs, and build each user's log_table within a parent dictionary. However, I don't think it would be any more efficient - for loops just seem more Pythonic :)