line_profiler.autoprofile.line_profiler_utils module¶
- line_profiler.autoprofile.line_profiler_utils.add_imported_function_or_module(self, item: CLevelCallable | Any, *, scoping_policy: ScopingPolicy | str | ScopingPolicyDict | None = None, wrap: bool = False) Literal[0][source]¶
- line_profiler.autoprofile.line_profiler_utils.add_imported_function_or_module(self, item: FunctionType | CythonCallable | type | partial | property | cached_property | MethodType | staticmethod | classmethod | partialmethod | ModuleType, *, scoping_policy: ScopingPolicy | str | ScopingPolicyDict | None = None, wrap: bool = False) Literal[0, 1]
Method to add an object to
LineProfilerto be profiled.This method is used to extend an instance of
LineProfilerso it can identify whether an object is a callable (wrapper), a class, or a module, and handle its profiling accordingly.- Parameters:
item (Union[Callable, Type, ModuleType]) – Object to be profiled.
scoping_policy (Union[ScopingPolicy, str, ScopingPolicyDict, None]) – Whether (and how) to match the scope of members and decide on whether to add them:
str(incl.ScopingPolicy):Strings are converted to
ScopingPolicyinstances in a case-insensitive manner, and the same policy applies to all members.{'func': ..., 'class': ..., 'module': ...}Mapping specifying individual policies to be enacted for the corresponding member types.
NoneThe default, equivalent to
DEFAULT_SCOPING_POLICIES.
See
line_profiler.line_profiler.ScopingPolicyandto_policies()for details.wrap (bool) – Whether to replace the wrapped members with wrappers which automatically enable/disable the profiler when called.
- Returns:
1 if any function is added to the profiler, 0 otherwise.
See also
DEFAULT_SCOPING_POLICIES,LineProfiler.add_callable(),LineProfiler.add_module(),LineProfiler.add_class(),ScopingPolicy,ScopingPolicy.to_policies()