def show_growth(limit=10, peak_stats={}, shortnames=True):
 gc.collect()
 stats = typestats(shortnames=shortnames)
 deltas = {}
 for (name, count) in iteritems(stats):
  old_count = peak_stats.get(name, 0)
  if (count > old_count):
   deltas[name] = (count - old_count)
   peak_stats[name] = count
 deltas = sorted(deltas.items(), key=operator.itemgetter(1), reverse=True)
 if limit:
  deltas = deltas[:limit]
 if deltas:
  width = max((len(name) for (name, count) in deltas))
  for (name, delta) in deltas:
   print ('%-*s%9d %+9d' % (width, name, stats[name], delta))

def show_growth ( limit = 10 , peak_stats = { } , shortnames = True ) : gc . collect ( ) stats = typestats ( shortnames = shortnames ) deltas = { } for ( name , count ) in iteritems ( stats ) : old_count = peak_stats . get ( name , 0 ) if ( count > old_count ) : deltas [ name ] = ( count - old_count ) peak_stats [ name ] = count deltas = sorted ( deltas . items ( ) , key = operator . itemgetter ( 1 ) , reverse = True ) if limit : deltas = deltas [ : limit ] if deltas : width = max ( ( len ( name ) for ( name , count ) in deltas ) ) for ( name , delta ) in deltas : print ( '%-*s%9d %+9d' % ( width , name , stats [ name ] , delta ) )
show the increase in peak object counts since last call .