line_profiler

Package Layout

  • line_profiler package
    • Subpackages
      • line_profiler.autoprofile package
        • Submodules
          • line_profiler.autoprofile.ast_profle_transformer module
            • ast_create_profile_node()
            • AstProfileTransformer
              • AstProfileTransformer.visit_FunctionDef()
              • AstProfileTransformer.visit_AsyncFunctionDef()
              • AstProfileTransformer.visit_Import()
              • AstProfileTransformer.visit_ImportFrom()
          • line_profiler.autoprofile.ast_tree_profiler module
            • AstTreeProfiler
              • AstTreeProfiler.profile()
          • line_profiler.autoprofile.autoprofile module
            • AutoProfile Script Demo
            • run()
          • line_profiler.autoprofile.eager_preimports module
            • is_dotted_path()
            • split_dotted_path()
            • resolve_profiling_targets()
            • write_eager_import_module()
          • line_profiler.autoprofile.line_profiler_utils module
            • add_imported_function_or_module()
          • line_profiler.autoprofile.profmod_extractor module
            • ProfmodExtractor
              • ProfmodExtractor.run()
          • line_profiler.autoprofile.run_module module
            • get_module_from_importfrom()
            • ImportFromTransformer
              • ImportFromTransformer.visit_ImportFrom()
            • AstTreeModuleProfiler
          • line_profiler.autoprofile.util_static module
            • package_modpaths()
            • modname_to_modpath()
            • split_modpath()
            • normalize_modpath()
            • modpath_to_modname()
        • Module contents
          • Auto-Profiling
    • Submodules
      • line_profiler.__main__ module
      • line_profiler._line_profiler module
        • LineProfiler
          • LineProfiler.add_function()
          • LineProfiler.c_code_map
          • LineProfiler.c_last_time
          • LineProfiler.code_hash_map
          • LineProfiler.code_map
          • LineProfiler.disable()
          • LineProfiler.disable_by_count()
          • LineProfiler.dupes_map
          • LineProfiler.enable()
          • LineProfiler.enable_by_count()
          • LineProfiler.enable_count
          • LineProfiler.functions
          • LineProfiler.get_stats()
          • LineProfiler.last_time
          • LineProfiler.set_frame_local_trace
          • LineProfiler.threaddata
          • LineProfiler.timer_unit
          • LineProfiler.tool_id
          • LineProfiler.wrap_trace
        • LineStats
        • _LineProfilerManager
          • _LineProfilerManager.__call__()
          • _LineProfilerManager.active_instances
          • _LineProfilerManager.handle_line_event()
          • _LineProfilerManager.handle_raise_event()
          • _LineProfilerManager.handle_reraise_event()
          • _LineProfilerManager.handle_return_event()
          • _LineProfilerManager.handle_yield_event()
          • _LineProfilerManager.set_frame_local_trace
          • _LineProfilerManager.wrap_local_f_trace()
          • _LineProfilerManager.wrap_trace
        • disable_line_events()
        • find_cython_source_file()
        • label()
      • line_profiler.cli_utils module
        • add_argument()
        • get_cli_config()
        • get_python_executable()
        • positive_float()
        • boolean()
        • short_string_path()
      • line_profiler.explicit_profiler module
        • GlobalProfiler
          • GlobalProfiler.enabled
          • GlobalProfiler.setup_config
          • GlobalProfiler.write_config
          • GlobalProfiler.output_prefix
          • GlobalProfiler.show_config
          • GlobalProfiler.enable()
          • GlobalProfiler.disable()
          • GlobalProfiler.__call__()
          • GlobalProfiler.show()
        • is_mp_bootstrap()
      • line_profiler.ipython_extension module
        • LineProfilerMagics
          • LineProfilerMagics.lprun()
          • LineProfilerMagics.lprun_all()
          • LineProfilerMagics.magics
          • LineProfilerMagics.registered
      • line_profiler.line_profiler module
        • LineProfiler
          • LineProfiler.__call__()
          • LineProfiler.add_callable()
          • LineProfiler.add_class()
          • LineProfiler.add_module()
          • LineProfiler.dump_stats()
          • LineProfiler.get_stats()
          • LineProfiler.print_stats()
          • LineProfiler.wrap_callable()
        • LineStats
          • LineStats.from_files()
          • LineStats.from_stats_objects()
          • LineStats.print()
          • LineStats.to_file()
        • get_code_block()
        • get_column_widths()
        • is_generated_code()
        • load_ipython_extension()
        • load_stats()
        • main()
        • show_func()
        • show_text()
      • line_profiler.profiler_mixin module
        • is_c_level_callable()
        • is_cython_callable()
        • is_classmethod()
        • is_staticmethod()
        • is_boundmethod()
        • is_partialmethod()
        • is_partial()
        • is_property()
        • is_cached_property()
        • ByCountProfilerMixin
          • ByCountProfilerMixin.wrap_callable()
          • ByCountProfilerMixin.get_underlying_functions()
          • ByCountProfilerMixin.wrap_classmethod()
          • ByCountProfilerMixin.wrap_staticmethod()
          • ByCountProfilerMixin.wrap_boundmethod()
          • ByCountProfilerMixin.wrap_partial()
          • ByCountProfilerMixin.wrap_partialmethod()
          • ByCountProfilerMixin.wrap_property()
          • ByCountProfilerMixin.wrap_cached_property()
          • ByCountProfilerMixin.wrap_async_generator()
          • ByCountProfilerMixin.wrap_coroutine()
          • ByCountProfilerMixin.wrap_generator()
          • ByCountProfilerMixin.wrap_function()
          • ByCountProfilerMixin.wrap_class()
          • ByCountProfilerMixin.run()
          • ByCountProfilerMixin.runctx()
          • ByCountProfilerMixin.runcall()
      • line_profiler.scoping_policy module
        • DEFAULT_SCOPING_POLICIES
        • ScopingPolicy
          • ScopingPolicy.EXACT
          • ScopingPolicy.CHILDREN
          • ScopingPolicy.DESCENDANTS
          • ScopingPolicy.SIBLINGS
          • ScopingPolicy.NONE
          • ScopingPolicy.get_filter()
          • ScopingPolicy.to_policies()
        • ScopingPolicyDict
          • ScopingPolicyDict.func
          • ScopingPolicyDict.class
          • ScopingPolicyDict.module
      • line_profiler.toml_config module
        • ConfigSource
          • ConfigSource.conf_dict
          • ConfigSource.path
          • ConfigSource.subtable
          • ConfigSource.copy()
          • ConfigSource.get_subconfig()
          • ConfigSource.from_default()
          • ConfigSource.from_config()
    • Module contents
      • Line Profiler
      • Installation
      • Line Profiler Basic Usage
      • Limitations
      • LineProfiler
        • LineProfiler.__call__()
        • LineProfiler.add_callable()
        • LineProfiler.add_class()
        • LineProfiler.add_module()
        • LineProfiler.dump_stats()
        • LineProfiler.get_stats()
        • LineProfiler.print_stats()
        • LineProfiler.wrap_callable()
      • LineStats
        • LineStats.from_files()
        • LineStats.from_stats_objects()
        • LineStats.print()
        • LineStats.to_file()
      • load_ipython_extension()
      • load_stats()
      • main()
      • show_func()
      • show_text()
  • line_profiler.autoprofile package
    • Submodules
      • line_profiler.autoprofile.ast_profle_transformer module
        • ast_create_profile_node()
        • AstProfileTransformer
          • AstProfileTransformer.visit_FunctionDef()
          • AstProfileTransformer.visit_AsyncFunctionDef()
          • AstProfileTransformer.visit_Import()
          • AstProfileTransformer.visit_ImportFrom()
      • line_profiler.autoprofile.ast_tree_profiler module
        • AstTreeProfiler
          • AstTreeProfiler.profile()
      • line_profiler.autoprofile.autoprofile module
        • AutoProfile Script Demo
        • run()
      • line_profiler.autoprofile.eager_preimports module
        • is_dotted_path()
        • split_dotted_path()
        • resolve_profiling_targets()
        • write_eager_import_module()
      • line_profiler.autoprofile.line_profiler_utils module
        • add_imported_function_or_module()
      • line_profiler.autoprofile.profmod_extractor module
        • ProfmodExtractor
          • ProfmodExtractor.run()
      • line_profiler.autoprofile.run_module module
        • get_module_from_importfrom()
        • ImportFromTransformer
          • ImportFromTransformer.visit_ImportFrom()
        • AstTreeModuleProfiler
      • line_profiler.autoprofile.util_static module
        • package_modpaths()
        • modname_to_modpath()
        • split_modpath()
        • normalize_modpath()
        • modpath_to_modname()
    • Module contents
      • Auto-Profiling
  • line_profiler.explicit_profiler module
    • GlobalProfiler
      • GlobalProfiler.enabled
      • GlobalProfiler.setup_config
      • GlobalProfiler.write_config
      • GlobalProfiler.output_prefix
      • GlobalProfiler.show_config
      • GlobalProfiler.enable()
      • GlobalProfiler.disable()
      • GlobalProfiler.__call__()
      • GlobalProfiler.show()
    • is_mp_bootstrap()
  • kernprof module
    • execfile()
    • ContextualProfile
      • ContextualProfile.__call__()
      • ContextualProfile.enable_by_count()
      • ContextualProfile.disable_by_count()
    • RepeatedTimer
      • RepeatedTimer.start()
      • RepeatedTimer.stop()
    • find_module_script()
    • find_script()
    • pre_parse_single_arg_directive()
    • no_op()
    • main()
  • Examples
line_profiler
  • Examples
  • View page source

ExamplesΒΆ

Examples of line profiler usage:

  • Basic Usage

  • Kernprof Usage

  • Auto Profiling

  • Explicit Profiler

  • Timing Units

  • TOML Config Usage

Previous

© Copyright 2025, Robert Kern.

Built with Sphinx using a theme provided by Read the Docs.