code: def gcstats():
      
      all = gc.get_objects()
      _stats = {}
  
      for obj in all:
          K = type(obj)
          if K is StatsDelta:
              continue  # avoid counting ourselves
  
          elif K is InstanceType:  # instance of an old-style class
              K = getattr(obj, '__class__', K)
  
          # Track types as strings to avoid holding references
          K = str(K)
  
          try:
              _stats[K] += 1
          except KeyError:
              _stats[K] = 1
  
      # explicitly break the reference loop between the list and this frame,
      # which is contained in the list
      # This would otherwise prevent the list from being free'd
      del all
  
      return _stats
docs: Count the number of instances of each type/class
  
      :returns: A dict() mapping type (as a string) to an integer number of references