-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
4,949 additions
and
84 deletions.
There are no files selected for viewing
Empty file.
0
CLAM.fdr_peak.MP.py → CLAM/bak/CLAM.fdr_peak.MP.py
100644 → 100755
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.