Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

hoxbro
Copy link
Member

@hoxbro hoxbro commented Apr 29, 2025

Continuing from #6476

I noticed that HoloViews was very slow when importing in IPython. This is mainly because of the import of Panel and Pandas. This PR defers these imports.

Hyperfine

Before (based on #6476)

hyperfine "ipython -c ''" "ipython -c 'import holoviews'" --warmup 5

❯ hyperfine "ipython -c ''" "ipython -c 'import holoviews'" --warmup 5
Benchmark 1: ipython -c ''
  Time (mean ± σ):     256.3 ms ±   2.9 ms    [User: 191.0 ms, System: 36.7 ms]
  Range (min … max):   252.2 ms … 260.9 ms    11 runs

Benchmark 2: ipython -c 'import holoviews'
  Time (mean ± σ):      1.398 s ±  0.017 s    [User: 2.820 s, System: 0.150 s]
  Range (min … max):    1.369 s …  1.416 s    10 runs

Summary
  ipython -c '' ran
    5.45 ± 0.09 times faster than ipython -c 'import holoviews'

After (this PR)

❯ hyperfine "ipython -c ''" "ipython -c 'import holoviews'" --warmup 5
Benchmark 1: ipython -c ''
  Time (mean ± σ):     256.7 ms ±   2.8 ms    [User: 194.2 ms, System: 34.5 ms]
  Range (min … max):   253.8 ms … 262.2 ms    11 runs

Benchmark 2: ipython -c 'import holoviews'
  Time (mean ± σ):     484.8 ms ±   5.7 ms    [User: 2020.4 ms, System: 57.8 ms]
  Range (min … max):   477.9 ms … 496.4 ms    10 runs

Summary
  ipython -c '' ran
    1.89 ± 0.03 times faster than ipython -c 'import holoviews'

Tuna

python -X importtime -m IPython -c 'import holoviews' 2> tuna.log && tuna tuna.log (and not having setuptools_scm installed)

Before (based on #6476)

image

After (this PR)

image

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 80.39216% with 10 lines in your changes missing coverage. Please review.

Project coverage is 88.81%. Comparing base (de3f00e) to head (373a129).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/ipython/__init__.py 50.00% 6 Missing ⚠️
holoviews/element/comparison.py 84.61% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6570      +/-   ##
==========================================
- Coverage   88.82%   88.81%   -0.01%     
==========================================
  Files         326      326              
  Lines       69449    69465      +16     
==========================================
+ Hits        61685    61697      +12     
- Misses       7764     7768       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from remove_direct_pandas to main May 12, 2025 16:16
@hoxbro hoxbro force-pushed the remove_slow_import_ipython branch from 5862f43 to 1f1a1a5 Compare May 12, 2025 16:20
@hoxbro hoxbro requested a review from maximlt May 13, 2025 11:15
Copy link
Member

@maximlt maximlt left a comment

Choose a reason for hiding this comment

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

Suggested one small improvement.

Co-authored-by: Maxime Liquet <[email protected]>
@hoxbro hoxbro enabled auto-merge (squash) May 13, 2025 13:37
@hoxbro hoxbro merged commit 5858c4c into main May 13, 2025
14 checks passed
@hoxbro hoxbro deleted the remove_slow_import_ipython branch May 13, 2025 13:49
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants