How to use the pympler.asizeof.basicsize function in Pympler

To help you get started, we’ve selected a few Pympler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pympler / pympler / test / asizeof / test_asizeof.py View on Github external
def _print_functions(self, obj, name=None, align=8, detail=MAX, code=False, limit=MAX,
                              opt='', **unused):
        if name:
            self._printf('%sasizeof functions for %s ... %s', os.linesep, name, opt)
        self._printf('%s(): %s', ' basicsize', asizeof.basicsize(obj))
        self._printf('%s(): %s', ' itemsize',  asizeof.itemsize(obj))
        self._printf('%s(): %r', ' leng',      asizeof.leng(obj))
        self._printf('%s(): %s', ' refs',     _repr(asizeof.refs(obj)))
        self._printf('%s(): %s', ' flatsize',  asizeof.flatsize(obj, align=align))  # , code=code
        self._printf('%s(): %s', ' asized',           asizeof.asized(obj, align=align, detail=detail, code=code, limit=limit))
      ##_printf('%s(): %s', '.asized',   _asizer.asized(obj, align=align, detail=detail, code=code, limit=limit))
github pympler / pympler / test / asizeof / test_asizeof.py View on Github external
def test_basicsize(self):
        '''Test asizeof.basicsize()
        '''
        objects = [1, '', 'a', True, None]
        for o in objects:
            self.assertEqual(asizeof.basicsize(o), type(o).__basicsize__)
        objects = [[], (), {}]
        for o in objects:
            self.assertEqual(asizeof.basicsize(o) - asizeof._sizeof_CPyGC_Head,
                type(o).__basicsize__)
        l1 = [1,2,3,4]
        l2 = ["spam",2,3,4,"eggs",6,7,8]
        self.assertEqual(asizeof.basicsize(l1), asizeof.basicsize(l2))
github pympler / pympler / test / asizeof / test_asizeof.py View on Github external
def test_basicsize(self):
        '''Test asizeof.basicsize()
        '''
        objects = [1, '', 'a', True, None]
        for o in objects:
            self.assertEqual(asizeof.basicsize(o), type(o).__basicsize__)
        objects = [[], (), {}]
        for o in objects:
            self.assertEqual(asizeof.basicsize(o) - asizeof._sizeof_CPyGC_Head,
                type(o).__basicsize__)
        l1 = [1,2,3,4]
        l2 = ["spam",2,3,4,"eggs",6,7,8]
        self.assertEqual(asizeof.basicsize(l1), asizeof.basicsize(l2))
github lrq3000 / pyFileFixity / pyFileFixity / lib / profilers / visual / pympler / classtracker.py View on Github external
callback). The size of the object is recorded in 'snapshots' as
        (timestamp, size) tuples.
        """
        self.ref = weakref_ref(instance, self.finalize)
        self.id = id(instance)
        self.repr = ''
        self.name = str(instance.__class__)
        self.birth = _get_time()
        self.death = None
        self._resolution_level = resolution_level
        self.trace = None

        if trace:
            self._save_trace()

        initial_size = asizeof.basicsize(instance) or 0
        size = asizeof.Asized(initial_size, initial_size)
        self.snapshots = [(self.birth, size)]
github pympler / pympler / pympler / classtracker.py View on Github external
callback). The size of the object is recorded in 'snapshots' as
        (timestamp, size) tuples.
        """
        self.ref = weakref_ref(instance, self.finalize)
        self.id = id(instance)
        self.repr = ''
        self.name = name
        self.birth = _get_time()
        self.death = None
        self._resolution_level = resolution_level
        self.trace = None

        if trace:
            self._save_trace()

        initial_size = asizeof.basicsize(instance) or 0
        size = asizeof.Asized(initial_size, initial_size)
        self.snapshots = [(self.birth, size)]
        self.on_delete = on_delete
github arjun-menon / Distributed-Graph-Algorithms / pympler / classtracker.py View on Github external
callback). The size of the object is recorded in 'snapshots' as
        (timestamp, size) tuples.
        """
        self.ref = weakref_ref(instance, self.finalize)
        self.id = id(instance)
        self.repr = ''
        self.name = str(instance.__class__)
        self.birth = _get_time()
        self.death = None
        self._resolution_level = resolution_level
        self.trace = None

        if trace:
            self._save_trace()

        initial_size = asizeof.basicsize(instance) or 0
        size = asizeof.Asized(initial_size, initial_size)
        self.snapshots = [(self.birth, size)]