line_profiler._line_profiler module¶
This is the Cython backend used in line_profiler.line_profiler
.
- class line_profiler._line_profiler.LineProfiler¶
Bases:
object
Time the execution of lines of Python code.
This is the Cython base class for
line_profiler.line_profiler.LineProfiler
.Example
>>> import copy >>> import line_profiler >>> # Create a LineProfiler instance >>> self = line_profiler.LineProfiler() >>> # Wrap a function >>> copy_fn = self(copy.copy) >>> # Call the function >>> copy_fn(self) >>> # Inspect internal properties >>> self.functions >>> self.c_last_time >>> self.c_code_map >>> self.code_map >>> self.last_time >>> # Print stats >>> self.print_stats()
- add_function(func)¶
Record line profiling information for the given Python function.
- c_code_map¶
A Python view of the internal C lookup table.
- c_last_time¶
- code_hash_map¶
- code_map¶
line_profiler 4.0 no longer directly maintains code_map, but this will construct something similar for backwards compatibility.
- disable()¶
- disable_by_count()¶
Disable the profiler if the number of disable requests matches the number of enable requests.
- dupes_map¶
- enable()¶
- enable_by_count()¶
Enable the profiler if it hasn’t been enabled before.
- enable_count¶
- functions¶
- get_stats()¶
Return a LineStats object containing the timings.
- last_time¶
line_profiler 4.0 no longer directly maintains last_time, but this will construct something similar for backwards compatibility.
- threaddata¶
- timer_unit¶
- class line_profiler._line_profiler.LineStats(timings, unit)¶
Bases:
object
Object to encapsulate line-profile statistics.
- line_profiler._line_profiler.__pyx_unpickle_LineProfiler(__pyx_type, __pyx_checksum, __pyx_state)¶
- line_profiler._line_profiler._code_replace(func, co_code)¶
Implements CodeType.replace for Python < 3.8
- line_profiler._line_profiler.label(code)¶
Return a (filename, first_lineno, func_name) tuple for a given code object.
This is the same labelling as used by the cProfile module in Python 2.5.