def typestats(objects=None, shortnames=True):
    if objects is None:
        objects = gc.get_objects()
    try:
        if shortnames:
            typename = _short_typename
        else:
            typename = _long_typename
        stats = {}
        for o in objects:
            n = typename(o)
            stats[n] = stats.get(n, 0) + 1
        return stats
    finally:
        del objects  # clear cyclic references to frame
Count the number of instances for each type tracked by the GC.
dataset/ETHPy150Open Exa-Networks/exabgp/lib/exabgp/dep/objgraph.py/typestats