

def typestats(objects=None, shortnames=True):
    "Count the number of instances for each type tracked by the GC.\n\n    Note that the GC does not track simple objects like int or str.\n\n    Note that classes with the same name but defined in different modules\n    will be lumped together if ``shortnames`` is True.\n\n    Example:\n\n        >>> typestats()\n        {'list': 12041, 'tuple': 10245, ...}\n        >>> typestats(get_leaking_objects())\n        {'MemoryError': 1, 'tuple': 2795, 'RuntimeError': 1, 'list': 47, ...}\n\n    .. versionadded:: 1.1\n\n    .. versionchanged:: 1.7\n       New parameter: ``objects``.\n\n    .. versionchanged:: 1.8\n       New parameter: ``shortnames``.\n\n    "
    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

dataset/ETHPy150Open Exa-Networks/exabgp/lib/exabgp/dep/objgraph.py typestats/original