Sections
Timeline
Browse Source
New Ticket
Sub-Sections
← Previous Ticket
Download
Comma-delimited Text
Tab-delimited Text
RSS Feed
Metanav
Preferences
About Trac
Links
Slowchop Studios
Gerald Kaszuba
Advertisement

Ticket #1 (closed defect: fixed)

Opened 22 months ago

Last modified 17 months ago

Filter out pycallgraph nodes

Reported by: gak Owned by: gak
Priority: trivial Component: general
Version: 0.3.0 Keywords:
Cc:

Description


Attachments

callback-filter.diff (5.0 kB) - added by Alec Thomas <alec@…> 22 months ago.
Callback filtering patch

Change History

Changed 22 months ago by gak

  • version changed from 0.2.0 to 0.2.1

Changed 22 months ago by Alec Thomas <alec@…>

I think a general callback filter would be the most elegant solution. Perhaps the following signature:

def filter(depth, module, thing):
    return True

Then perhaps have some useful utility filters builtin:

import fnmatch

class GlobFilter(object):
    def __init__(self, include=[], exclude=[]):
       ...

    def __call__(self, depth, module, thing):
       # Match module.thing against the include/exclude glob lists
       ...

Changed 22 months ago by Alec Thomas <alec@…>

Callback filtering patch

Changed 22 months ago by Alec Thomas <alec@…>

Here's an example of a custom filter which subclasses the default GlobbingFilter and prints as it traces:

import pycallgraph

class Filter(pycallgraph.GlobbingFilter):
    def __call__(self, stack, module, cls, func, full_name):
        if pycallgraph.GlobbingFilter.__call__(self, stack, module, cls, func, full_name):
            print '  ' * len(stack) + full_name

pycallgraph.start_trace(filter=Filter(exclude=['pycallgraph.*']))

def foo():
    print "foo()"

def bar():
    foo()
    foo()

bar()

pycallgraph.make_graph('test.png')

Changed 22 months ago by Alec Thomas <alec@…>

Or a more basic trace:

def print_me(stack, module, cls, func, full_name):
   print '  ' * len(stack) + full_name

pycallgraph.start_trace(filter=print_me)

Changed 22 months ago by gak

  • status changed from new to closed
  • version changed from 0.2.1 to 0.3.0
  • resolution set to fixed

Add/Change #1 (Filter out pycallgraph nodes)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.