Skip to content

Commit

Permalink
update to v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
zj-zhang committed Sep 18, 2017
1 parent 76ad8f9 commit d2244f0
Show file tree
Hide file tree
Showing 26 changed files with 4,949 additions and 84 deletions.
Empty file added CLAM/__init__.py
Empty file.
File renamed without changes.
546 changes: 546 additions & 0 deletions CLAM/bak/CLAM.lite_aligner.py

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions CLAM/bak/deep_getsizeof.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from collections import Mapping, Container
from sys import getsizeof

def deep_getsizeof(o, ids):
"""Find the memory footprint of a Python object
This is a recursive function that drills down a Python object graph
like a dictionary holding nested dictionaries with lists of lists
and tuples and sets.
The sys.getsizeof function does a shallow size of only. It counts each
object inside a container as pointer only regardless of how big it
really is.
:param o: the object
:param ids:
:return:
"""
d = deep_getsizeof
if id(o) in ids:
return 0

r = getsizeof(o)
ids.add(id(o))

if isinstance(o, str) or isinstance(0, unicode):
return r

if isinstance(o, Mapping):
return r + sum(d(k, ids) + d(v, ids) for k, v in o.iteritems())

if isinstance(o, Container):
return r + sum(d(x, ids) for x in o)

return r
Loading

0 comments on commit d2244f0

Please sign in to comment.