Skip to content
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

Lazy-load pandas #855

Merged
merged 2 commits into from
Nov 12, 2024
Merged

Lazy-load pandas #855

merged 2 commits into from
Nov 12, 2024

Conversation

mattwthompson
Copy link
Contributor

Description

Currently, a little less than half of the time taken to import anything from QCPortal is spend dealing with Pandas. I think most use cases don't involve its direct use, so it can be loaded later when needed. This improvement should propagate to downstream packages which want to i.e. use PortalClient or build off of record models but don't need Pandas.

Before:

$ hyperfine \                                                                    14:31:18  ☁  4ebcd88f ☀
    'python -c "from qcportal import PortalClient"' \
    --prepare \
    'python -c "from qcportal import PortalClient"'
Benchmark 1: python -c "from qcportal import PortalClient"
  Time (mean ± σ):     621.8 ms ±  10.0 ms    [User: 514.2 ms, System: 96.5 ms]
  Range (min … max):   608.4 ms … 642.9 ms    10 runs
$ python -X importtime -c "from qcportal import PortalClient" 2> tuna.log && tuna tuna.log

image

With these changes:

$ fc                                                                     14:27:45  ☁  lazy-load-pandas ☀
hyperfine \
    'python -c "from qcportal import PortalClient"' \
    --prepare \
    'python -c "from qcportal import PortalClient"'
Benchmark 1: python -c "from qcportal import PortalClient"
  Time (mean ± σ):     375.1 ms ±   7.5 ms    [User: 318.7 ms, System: 50.1 ms]
  Range (min … max):   368.1 ms … 394.3 ms    10 runs

Status

  • Code base linted
  • Ready to go

@bennybp
Copy link
Contributor

bennybp commented Nov 12, 2024

Sounds good to me.

I think the CI errors are from conda resolving some older pytest version with python 3.8. Since python 3.8 is now EOL, I can probably take that out of the CI. Would you agree?

@mattwthompson
Copy link
Contributor Author

Sure, I've made an attempt in #856

@mattwthompson mattwthompson marked this pull request as ready for review November 12, 2024 14:42
@bennybp bennybp merged commit 99e7b82 into MolSSI:main Nov 12, 2024
15 checks passed
@bennybp
Copy link
Contributor

bennybp commented Nov 12, 2024

Thanks! This is great, I'm always looking for performance increases

@mattwthompson mattwthompson deleted the lazy-load-pandas branch November 12, 2024 16:33
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