A collection of functions to summarize object information.
This module provides several function which will help you to analyze object information which was gathered. Often it is sufficient to work with aggregated data instead of handling the entire set of existing objects. For example can a memory leak identified simple based on the number and size of existing objects.
A summary contains information about objects in a table-like manner. Technically, it is a list of lists. Each of these lists represents a row, whereas the first column reflects the object type, the second column the number of objects, and the third column the size of all these objects. This allows a simple table-like output like the following:
|types||# objects||total size|
Another advantage of summaries is that they influence the system you analyze only to a minimum. Working with references to existing objects will keep these objects alive. Most of the times this is no desired behavior (as it will have an impact on the observations). Using summaries reduces this effect greatly.
The output representation of types is defined in summary.representations. Every type defined in this dictionary will be represented as specified. Each definition has a list of different representations. The later a representation appears in this list, the higher its verbosity level. From types which are not defined in summary.representations the default str() representation will be used.
Per default, summaries will use the verbosity level 1 for any encountered type. The reason is that several computations are done with summaries and rows have to remain comparable. Therefore information which reflect an objects state, e.g. the current line number of a frame, should not be included. You may add more detailed information at higher verbosity levels than 1.
Summarize an objects list.
- Return a list of lists, whereas each row consists of::
- [str(type), number of objects of this type, total size of these objects].
No guarantee regarding the order is given.
Get the difference of two summaries.
Subtracts the values of the right summary from the values of the left summary. If similar rows appear on both sides, the are included in the summary with 0 for number of elements and total size. If the number of elements of a row of the diff is 0, but the total size is not, it means that objects likely have changed, but not there number, thus resulting in a changed size.
print_(rows, limit=15, sort='size', order='descending')¶
Print the rows as a summary.
Keyword arguments: limit – the maximum number of elements to be listed sort – sort elements by ‘size’, ‘type’, or ‘#’ order – sort ‘ascending’ or ‘descending’