Table of Contents

Module: annotate src/annotate.py

Various functions to add information to the wrapper objects.

The information might be lost when you copy the wrappers (using wrappers.copy() or operations.fix(wrappers). This is a bug.

Functions   
_groupfrom
_toset
addcontained
findcreators
findcycles
findcyclesfrom
flatten
groupby
markparents
simplegroupby
  _groupfrom 
_groupfrom (
        wrappers,
        g,
        w,
        parent,
        childtime,
        groups,
        split,
        )

  _toset 
_toset ( l )

Turns a list into a set. If it's already a set, returns the input (not even a shallow copy).

  addcontained 
addcontained ( wrappers )

If an object has only one parent, include it in the size of the parent. This should go some way towards making sizes accurate.

Note: this won't include any cyclic references.

  findcreators 
findcreators ( wrappers )

Given a set of wrappers, returns a structure which can be used to find what objects each line of code created.

The structure it returns has a "members" field, which contains all scanned objects, a "size" field, which gives the total size of all objects, and a "back" field, which contains a dictionary with a structure for each function that created an object. The dict maps from (file name, line number) or None to structure. None is used when there are no functions to go back to - i.e. it was this function that started the sequence of calls that led to the creation of the object.

Following a member of "back" will give a structure with "filename" and "line" fields. In this structure, the "members" field contains the objects that were created on this file/line, and the "size" field the size of those objects.

The "back" field contains a dictionary with a structure for each function that had called this function to make an object.

You can print these using formatting.printsizes(creators.back) where creators is the value returned by this function.

Exceptions   
Exception, "Couldn't find cpython.utils.objframe - " + "you need a patched copy of Python, and you need to " "build the profiler using that copy."
  findcycles 
findcycles ( wrappers )

Yields all cycles in the wrappers.

  findcyclesfrom 
findcyclesfrom (
        w,
        cycles,
        path,
        )

Yields all cycles that can be found from w.

  flatten 
flatten (
        wrappers,
        order=pre,
        head=None,
        cycle=None,
        )

Iterate through wrappers, yielding a pre-order traversal of the form (wrapper, parent), where parent is None for head.

In case of a cycle (which just about every set of objects will have), the function "cycle" is called on the wrapper, which by default does nothing.

  groupby 
groupby (
        wrappers,
        groups,
        split=None,
        )

Assign each object in wrappers to a member of groups. Returns a dictionary which maps from object id to ObjectWrapper. Objects which can't be put in a group are put in noGroup.

Also sets group, time and parent for each object, and members and totalSize for each group.

For example, setting groups to a list of modules will assign each object to a module.

split is a set of objects which mark the end of a group - once they're reached they're not looked at further. By default it's the set of groups so, for example, if module A contains module B objects that can only be reached via B will not be grouped under A.

  markparents 
markparents ( wrappers )

Add a field "parents" to each wrapper, containing the objects which reference the child object.

  simplegroupby 
simplegroupby (
        wrappers,
        modules=False,
        threads=False,
        classes=False,
        )

Assign each object in wrappers to a module, thread or class. The values of "modules", "threads" and "classes" control whether those are included (for example, having modules = True, threads = classes = False will assign each object to a module only).

Returns a dictionary mapping from module ID or id(noGroup) to module object.

Also sets "group" and "time" fields for each object, and "members" for each module.

Classes   

GroupWrapper

NoGroup

This is used to collect groupless objects

NoGroupWrapper

_Creator

A structure representing a particular series of calls to


Table of Contents

This document was automatically generated on Mon Apr 3 22:34:29 2006 by HappyDoc version 2.1