Skip to content

move httpx imports to function scope#5612

Merged
adhami3310 merged 4 commits into
mainfrom
move-httpx-imports-to-function-scope
Jul 22, 2025
Merged

move httpx imports to function scope#5612
adhami3310 merged 4 commits into
mainfrom
move-httpx-imports-to-function-scope

Conversation

@adhami3310

Copy link
Copy Markdown
Member

No description provided.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR is focused on optimizing imports across the codebase by moving httpx imports from module-level to function-level scope. The changes span multiple files and are part of a larger performance optimization initiative. The main goals are:

  1. Improve application startup time by lazy-loading the httpx library only when needed
  2. Reduce memory usage when network functionality isn't required
  3. Follow Python best practices for import optimization

The changes are consistently applied across the following key files:

  • custom_components.py
  • telemetry.py
  • net.py
  • redir.py
  • registry.py

Additionally, the PR introduces disk caching functionality in registry.py for optimizing best registry selection.

Confidence score: 4/5

  1. This PR is generally safe to merge as it's a straightforward optimization pattern.
  2. The score is 4/5 because while the changes follow best practices and are well-structured, the distributed nature of the changes across multiple files introduces a small risk of integration issues.
  3. Files needing more attention:
    • prerequisites.py: This file has inconsistent changes noted in the summary and needs review
    • registry.py: The new caching functionality should be tested thoroughly

8 files reviewed, 5 comments

Edit Code Review Bot Settings | Greptile

Comment thread reflex/utils/net.py
Comment thread reflex/utils/redir.py Outdated
Comment thread reflex/utils/decorator.py Outdated
Comment thread reflex/utils/decorator.py
Comment thread tests/units/test_prerequisites.py
@codspeed-hq

codspeed-hq Bot commented Jul 22, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #5612 will not alter performance

Comparing move-httpx-imports-to-function-scope (4c66945) with main (7e0a95f)

Summary

✅ 8 untouched benchmarks

@masenf masenf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this mainly just to speed up import reflex?

@adhami3310

Copy link
Copy Markdown
Member Author

is this mainly just to speed up import reflex?

yea

@adhami3310 adhami3310 merged commit 60b580b into main Jul 22, 2025
39 of 41 checks passed
@adhami3310 adhami3310 deleted the move-httpx-imports-to-function-scope branch July 22, 2025 23:13
masenf added a commit that referenced this pull request Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants