pooltool.utils ============== .. py:module:: pooltool.utils Utilities --------- Overview -------- .. list-table:: Classes :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`classproperty ` - Decorator for a class property .. list-table:: Function :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`save_pickle `\ (x, path) - Save an object `x` to filepath `path` * - :py:obj:`is_pickleable `\ (obj) - https://stackoverflow.com/a/53398070 * - :py:obj:`get_total_memory_usage `\ (keep_raw) - Get the total memory, including children * - :py:obj:`display_top_memory_usage `\ (snapshot, key_type, limit) - A pretty-print for the tracemalloc memory usage module Classes ------- .. autoclass:: classproperty Bases: :py:obj:`property` Functions --------- .. py:function:: save_pickle(x, path) Save an object `x` to filepath `path` .. py:function:: is_pickleable(obj) https://stackoverflow.com/a/53398070 .. py:function:: get_total_memory_usage(keep_raw=False) Get the total memory, including children :param keep_raw: A human readable format is returned, e.g. "1.41 GB". If keep_raw, the raw number is returned, e.g. 1515601920 :type keep_raw: bool, False .. py:function:: display_top_memory_usage(snapshot, key_type='lineno', limit=10) A pretty-print for the tracemalloc memory usage module Modified from https://docs.python.org/3/library/tracemalloc.html .. admonition:: Examples >>> import tracemalloc >>> import pooltool.utils as utils >>> tracemalloc.start() >>> snap = tracemalloc.take_snapshot >>> utils.display_top_memory_usage(snap) Top 10 lines #1: anvio/bamops.py:160: 4671.3 KiB constants.cigar_consumption, #2: anvio/bamops.py:96: 2571.6 KiB self.cigartuples = np.array(read.cigartuples) #3: python3.6/linecache.py:137: 1100.0 KiB lines = fp.readlines() #4: :487: 961.4 KiB #5: typing/templates.py:627: 334.3 KiB return type(base)(name, (base,), dct) #6: typing/templates.py:923: 315.7 KiB class Template(cls): #7: python3.6/_weakrefset.py:84: 225.2 KiB self.data.add(ref(item, self._remove)) #8: targets/npyimpl.py:411: 143.2 KiB class _KernelImpl(_Kernel): #9: _vendor/pyparsing.py:3349: 139.7 KiB self.errmsg = "Expected " + _ustr(self) #10: typing/context.py:456: 105.1 KiB def on_disposal(wr, pop=self._globals.pop): 3212 other: 4611.9 KiB Total allocated size: 15179.4 KiB