Skip to content

Commit d2244f0

Browse files
committed
update to v1.1
1 parent 76ad8f9 commit d2244f0

26 files changed

+4949
-84
lines changed

CLAM/__init__.py

Whitespace-only changes.
File renamed without changes.

CLAM/bak/CLAM.lite_aligner.py

Lines changed: 546 additions & 0 deletions
Large diffs are not rendered by default.

CLAM/bak/deep_getsizeof.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from collections import Mapping, Container
2+
from sys import getsizeof
3+
4+
def deep_getsizeof(o, ids):
5+
"""Find the memory footprint of a Python object
6+
7+
This is a recursive function that drills down a Python object graph
8+
like a dictionary holding nested dictionaries with lists of lists
9+
and tuples and sets.
10+
11+
The sys.getsizeof function does a shallow size of only. It counts each
12+
object inside a container as pointer only regardless of how big it
13+
really is.
14+
15+
:param o: the object
16+
:param ids:
17+
:return:
18+
"""
19+
d = deep_getsizeof
20+
if id(o) in ids:
21+
return 0
22+
23+
r = getsizeof(o)
24+
ids.add(id(o))
25+
26+
if isinstance(o, str) or isinstance(0, unicode):
27+
return r
28+
29+
if isinstance(o, Mapping):
30+
return r + sum(d(k, ids) + d(v, ids) for k, v in o.iteritems())
31+
32+
if isinstance(o, Container):
33+
return r + sum(d(x, ids) for x in o)
34+
35+
return r

0 commit comments

Comments
 (0)