line_profiler.profiler_mixin module

line_profiler.profiler_mixin.is_c_level_callable(func: Any) TypeIs[CLevelCallable][source]
Returns:

Whether a callable is defined at the C-level (and is thus non-profilable).

Return type:

func_is_c_level (bool)

line_profiler.profiler_mixin.is_cython_callable(func: Any) TypeIs[CythonCallable][source]
line_profiler.profiler_mixin.is_classmethod(f: Any) TypeIs[classmethod][source]
line_profiler.profiler_mixin.is_staticmethod(f: Any) TypeIs[staticmethod][source]
line_profiler.profiler_mixin.is_boundmethod(f: Any) TypeIs[types.MethodType][source]
line_profiler.profiler_mixin.is_partialmethod(f: Any) TypeIs[partialmethod][source]
line_profiler.profiler_mixin.is_partial(f: Any) TypeIs[partial][source]
line_profiler.profiler_mixin.is_property(f: Any) TypeIs[property][source]
line_profiler.profiler_mixin.is_cached_property(f: Any) TypeIs[cached_property][source]
class line_profiler.profiler_mixin.ByCountProfilerMixin[source]

Bases: object

Mixin class for profiler methods built around the enable_by_count() and disable_by_count() methods, rather than the enable() and disable() methods.

Used by line_profiler.line_profiler.LineProfiler and kernprof.ContextualProfile.

enable_by_count() None[source]
disable_by_count() None[source]
wrap_callable(func: Callable) Callable[source]

Decorate a function to start the profiler on function entry and stop it on function exit.

classmethod get_underlying_functions(func: object) list[LambdaType | cython_function_or_method][source]

Get the underlying function objects of a callable or an adjacent object.

Returns:

funcs (list[Callable])

wrap_classmethod(func)

Wrap a classmethod() or staticmethod() to profile it.

wrap_staticmethod(func)

Wrap a classmethod() or staticmethod() to profile it.

wrap_boundmethod(func)[source]

Wrap a types.MethodType to profile it.

wrap_partial(func)

Wrap a functools.partial() or functools.partialmethod to profile it.

wrap_partialmethod(func)

Wrap a functools.partial() or functools.partialmethod to profile it.

wrap_property(func)[source]

Wrap a property to profile it.

wrap_cached_property(func)[source]

Wrap a functools.cached_property() to profile it.

wrap_async_generator(func)[source]

Wrap an async generator function to profile it.

wrap_coroutine(func)[source]

Wrap a coroutine function to profile it.

wrap_generator(func)[source]

Wrap a generator function to profile it.

wrap_function(func)[source]

Wrap a function to profile it.

wrap_class(func)[source]

Wrap a class by wrapping all locally-defined callables and callable wrappers.

Returns:

The class passed in, with its locally-defined callables and wrappers wrapped.

Return type:

func (type)

Warns:

UserWarning – If any of the locally-defined callables and wrappers cannot be replaced with the appropriate wrapper returned from wrap_callable().

run(cmd)[source]

Profile a single executable statment in the main namespace.

runctx(cmd, globals, locals)[source]

Profile a single executable statement in the given namespaces.

runcall(func, /, *args, **kw)[source]

Profile a single function call.