Skip to content

Conversation

@pablogsal
Copy link
Member

@pablogsal pablogsal commented Dec 28, 2025

The sampling profiler code had numerous imports placed inside functions
rather than at module level. While deferred imports can reduce startup
time for rarely-used code paths, these imports were in functions called
during normal profiler operation, adding repeated import overhead.

Moving imports to module level follows Python best practices for code
that runs frequently. This makes import dependencies explicit at file
scope and eliminates per-call import lookup costs. The test files also
had redundant local imports that duplicated module-level imports.

The sampling profiler code had numerous imports placed inside functions
rather than at module level. While deferred imports can reduce startup
time for rarely-used code paths, these imports were in functions called
during normal profiler operation, adding repeated import overhead.

Moving imports to module level follows Python best practices for code
that runs frequently. This makes import dependencies explicit at file
scope and eliminates per-call import lookup costs. The test files also
had redundant local imports that duplicated module-level imports.
@picnixz picnixz changed the title Move local imports to module level in sampling profiler gh-138122: Move local imports to module level in sampling profiler Dec 28, 2025
@picnixz picnixz added the type-refactor Code refactoring (with no changes in behavior) label Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news type-refactor Code refactoring (with no changes in behavior)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants