def pstats2entries(data):
 entries = dict()
 allcallers = dict()
 for (code_info, call_info) in data.stats.items():
  code = Code()
  (code.co_filename, code.co_firstlineno, code.co_name) = code_info
  (cc, nc, tt, ct, callers) = call_info
  entry = Entry()
  entry.code = code
  entry.callcount = cc
  entry.reccallcount = (nc - cc)
  entry.inlinetime = tt
  entry.totaltime = ct
  entry.calls = list()
  entries[code_info] = entry
  allcallers[code_info] = callers.items()
 for entry in entries.itervalues():
  entry_label = cProfile.label(entry.code)
  entry_callers = allcallers.get(entry_label, [])
  for (entry_caller, call_info) in entry_callers:
   entries[entry_caller].calls.append((entry, call_info))
 return entries.values()

def pstats2entries ( data ) : entries = dict ( ) allcallers = dict ( ) for ( code_info , call_info ) in data . stats . items ( ) : code = Code ( ) ( code . co_filename , code . co_firstlineno , code . co_name ) = code_info ( cc , nc , tt , ct , callers ) = call_info entry = Entry ( ) entry . code = code entry . callcount = cc entry . reccallcount = ( nc - cc ) entry . inlinetime = tt entry . totaltime = ct entry . calls = list ( ) entries [ code_info ] = entry allcallers [ code_info ] = callers . items ( ) for entry in entries . itervalues ( ) : entry_label = cProfile . label ( entry . code ) entry_callers = allcallers . get ( entry_label , [ ] ) for ( entry_caller , call_info ) in entry_callers : entries [ entry_caller ] . calls . append ( ( entry , call_info ) ) return entries . values ( )
helper to convert serialized pstats back to a list of raw entries converse opperation of cprofile .