Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
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))
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))
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)]
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
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)]