Skip to content

Lazy-import urllib and pyautogui to cut about a second from cold start #163

Closed

Description

@TMHSDigital

Summary

Most of the cold start before the window appears is imports the first frame does not need.

Where

  • autoclicker/core/click_engine.py:16
  • autoclicker/core/updates.py (urllib.request at import)
  • docs/PERFORMANCE.md:26

Details

python -X importtime -c "import autoclicker.main": tkinter and PIL about 130 ms; import pyautogui 510 to 1147 ms (mouseinfo about 495 ms self time, pyscreeze 388 ms including pyrect -> doctest); autoclicker.core.updates -> urllib.request about 157 ms, although the update check runs 1.5 s after launch.

Impact

0.5 to 1 s added to every GUI launch and every headless CLI run.

Suggested fix

Import urllib.request inside the update-check function. Import pyautogui lazily in the click engine (first use) so the window appears first. See the pyautogui replacement issue for the longer-term fix.

Acceptance criteria

  • import autoclicker.main no longer imports urllib.request or pyautogui
  • Engine tests still patch autoclicker.core.click_engine.pyautogui successfully

Getting started

  • Relevant files: autoclicker/core/updates.py, autoclicker/core/click_engine.py
  • How to run tests: make check (Git Bash) or tasks.bat lint, tasks.bat typecheck, tasks.bat test (cmd). Single test: python -m pytest tests/test_x.py::TestClass::test_name --no-cov
  • Related docs: CONTRIBUTING.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 9968dc8. Severity: low. Effort: S. audit-key: performance|autoclicker/core/click_engine.py|import pyautogui

Activity

  1. added
    priority: low
    performance
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancepriority: low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions