1.3.1.1 Turning the debugger on an off and using Pdb.precmd

Since the debugger slows things down looking for stoppoing points. If you want to remove this overhead and have Python run closer to full speed, here's how you can remove the debugger hook:

    sys.settrace(None)

If you need to turn it on subsequently:

    pydb.debugger(status='continue')

If there's something you want to run before stepping you can do that by monkey-patching Pdb.precmd:

import pydb
def myprecmd(obj, debug_cmd):
    """Hook method executed just after a command dispatch is finished."""
    global _pydb_trace
    obj.do_list('')
    obj.do_where('10')  # limit stack to at most 10 entries
    return obj.old_precmd(debug_cmd)  # is always string 's' in example below

_pydb_trace = pydb.Pdb()
pydb.Pdb.old_precmd = pydb.Pdb.precmd
pydb.Pdb.precmd = myprecmd
pydb.debugger(dbg_cmds=['s'] * 30)

See About this document... for information on suggesting changes.