# eric3.DebugClients.Python.PyProfile

Module defining additions to the standard Python profile.py.

### Classes

PyProfile | Class extending the standard Python profiler with additional methods.

### Functions

None

## PyProfile

Class extending the standard Python profiler with additional methods.

This class extends the standard Python profiler by the functionality to save the collected timing data in a timing cache, to restore these data on subsequent calls, to store a profile dump to a standard filename and to erase these caches.

### Derived from

profile.Profile

### Methods

PyProfile | Constructor
erase | Public method to erase the collected timing data.
fix_frame_filename | Protected method used to fixup the filename for a given frame.
restore | Private method to restore the timing data from the timing cache.
save | Public method to store the collected profile data.
trace_dispatch_call | Private method used to trace functions calls.

### PyProfile (Constructor)

PyProfile(basename, timer=None, bias=None)

Constructor

basename
  name of the script to be profiled (string)
timer
  function defining the timing calculation
bias
  calibration value (float)

### PyProfile.erase

erase()

Public method to erase the collected timing data.

### PyProfile.fix_frame_filename

fix_frame_filename(frame)

Protected method used to fixup the filename for a given frame.

The logic employed here is that if a module was loaded from a .pyc file, then the correct .py to operate with should be in the same path as the .pyc. The reason this logic is needed is that when a .pyc file is generated, the filename embedded and thus what is readable in the code object of the frame object is the fully qualified filepath when the pyc is generated. If files are moved from machine to machine this can break debugging as the .pyc will refer to the .py on the original machine. Another case might be sharing code over a network... This logic deals with that.

frame
  the frame object

### PyProfile.restore

restore()

Private method to restore the timing data from the timing cache.

### PyProfile.save

save()

Public method to store the collected profile data.

### PyProfile.trace_dispatch_call

trace_dispatch_call(frame, t)

Private method used to trace functions calls.

This is a variant of the one found in the standard Python profile.py calling fix_frame_filename above.

Up