Skip to content

Slow import times #2339

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
1 task done
serozhenka opened this issue May 3, 2025 · 2 comments
Open
1 task done

Slow import times #2339

serozhenka opened this issue May 3, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@serozhenka
Copy link

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

On average, it takes nearly 0.5 seconds to just import openai.

That may sound normal, but consider the case where a bunch of deps are imported and each one of them takes 0.5 seconds to be imported. Startup times of such an application go crazy.

To Reproduce

import time

start = time.time()
import openai

print(time.time() - start)

Alternatively, run:

python -X importtime -c "import openai"

Code snippets

OS

macOS

Python version

3.11.9

Library version

1.75.0

@serozhenka serozhenka added the bug Something isn't working label May 3, 2025
@RobertCraigie
Copy link
Collaborator

@serozhenka can you try the latest changes in #2340?

pip install git+https://github.com/openai/openai-python.git@next

@serozhenka
Copy link
Author

serozhenka commented May 6, 2025

@RobertCraigie
Yeah, much better, down to .25s on average. Appreciate the work on the lazy imports.
I think it can still be further improved by not trying to import from all of the modules in root __init__.py, but this would affect too many people to even be discussed, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants