Skip to content

Switch to lazy exports #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Switch to lazy exports #22

wants to merge 15 commits into from

Conversation

flying-sheep
Copy link
Member

@flying-sheep flying-sheep commented Feb 18, 2025

On my systems, this speeds up import:

  • 1.26s→0.91s on Linux (1.38× speed improvement)
  • 1.47s→1.07s on macOS (1.37× speed improvement)

(in an environment with everything except Cupy installed)

TODO:

  • figure out lazy singledispatch

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

Attention: Patch coverage is 95.69892% with 4 lines in your changes missing coverage. Please review.

Project coverage is 96.86%. Comparing base (a7e216b) to head (a83784b).

Files with missing lines Patch % Lines
src/fast_array_utils/_import.py 90.69% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
- Coverage   96.95%   96.86%   -0.10%     
==========================================
  Files          11       12       +1     
  Lines         164      223      +59     
==========================================
+ Hits          159      216      +57     
- Misses          5        7       +2     

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

Copy link

codspeed-hq bot commented Feb 18, 2025

CodSpeed Performance Report

Merging #22 will improve performances by ×3.6

Comparing pa/lazy (a83784b) with main (a7e216b)

Summary

⚡ 2 improvements
✅ 50 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
test_stats_benchmark[1-scipy.sparse.csr_array-float32-is_constant] 417.3 µs 115 µs ×3.6
test_stats_benchmark[1-scipy.sparse.csr_array-float64-is_constant] 250.1 µs 148.5 µs +68.43%

@flying-sheep flying-sheep marked this pull request as ready for review February 20, 2025 11:17
Copy link
Contributor

@ilan-gold ilan-gold left a comment

Choose a reason for hiding this comment

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

So the goal of this is to speed up imports? Looking at the code, I'm not sure it's worth this level of complexity TBH.

Things like:

@_sum.register("dask.array:Array")

make me cringe a bit. I would need to let this sit with me for a bit before I'd give it a sign-off. I'm very hesitant

@flying-sheep
Copy link
Member Author

The syntax is actually a Python standard used in entry points, e.g. scripts and all others that I know of, e.g. pygments lexers, pytest plugins, web services (WSGI/ASGI, e.g. uvicorn main:app), …

@ilan-gold
Copy link
Contributor

ilan-gold commented Feb 20, 2025

I meant more creating a custom register based on this, not the syntax itself of the string.

@ilan-gold
Copy link
Contributor

I think honestly that I don't see the tradeoff here worth it IMO. I think the complexity of this sort of thing can make our code unapproachable to people who might want to contribute. I understand if the complexity is really necessary here, but I don't personally feel it is needed here :/

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