Skip to content

Conversation

@ofek
Copy link
Contributor

@ofek ofek commented Jul 31, 2025

I agree with the intention to lazily import but it wasn't actually happening. Locally I get the following on Python 3.12:

❯ python -m timeit -n 1 -r 1 "import shutil"
1 loop, best of 1: 8.09 msec per loop

@ofek
Copy link
Contributor Author

ofek commented Jul 31, 2025

Okay, that's everything!

@davidism
Copy link
Member

Can you target this at stable instead?

@davidism
Copy link
Member

There's a test that checks what modules are imported, you can probably remove shutil from that list as well.

@ofek ofek changed the base branch from main to stable July 31, 2025 20:25
@ofek
Copy link
Contributor Author

ofek commented Jul 31, 2025

I changed to stable and updated that test! If it's fine with you, I'm interested in the coming weeks/months making sure that everything (within reason) is lazily imported.

@davidism
Copy link
Member

davidism commented Jul 31, 2025

Definitely, it's a bit annoying to code, but I think the speed is worth it for the CLI. We want to distinguish between what's going to be imported no matter what (general Python startup / used everywhere anyway) versus what only comes up in certain use cases. That's what that import test is for, so we know if something gets imported unintentionally, and can review imports from time to time.

@Rowlando13
Copy link
Collaborator

Rowlando13 commented Aug 7, 2025

@ofek Can you rebase onto current stable. There are my commits that merge stable into master on the branch. Same thing happened to me and I am not sure how exactly.

@ofek
Copy link
Contributor Author

ofek commented Aug 8, 2025

Done!

@Rowlando13 Rowlando13 merged commit 1f40020 into pallets:stable Aug 8, 2025
10 checks passed
@ofek ofek deleted the patch-1 branch August 8, 2025 20:00
@kdeldycke kdeldycke added this to the 8.2.3 milestone Aug 12, 2025
@Rowlando13
Copy link
Collaborator

@ofek Could you please add a change entry for this on another PR. I did not see there was not one.

@AndreasBackx
Copy link
Collaborator

I'll take care of the CHANGES mention, don't worry about it.

@Rowlando13 Rowlando13 modified the milestones: 8.2.3, 8.3.0 Aug 24, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 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.

5 participants