-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
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 a long time to run import openai on recent hardware and software.
Average of 2 seconds on:
- Windows 11 with
- Intel(R) Core(TM) Ultra 7 165H (3.80 GHz)
- 32.0 GB (31.6 GB usable)
Average of 0.7 seconds on:
- Ubuntu 24.04 HP Z420 workstation
- Intel Xeon E5-1650 v2 x 12
- 64.0 Gib
If that sounds normal, consider the case where a bunch of deps are imported and each one of them takes 2 seconds to be imported. For example, I discovered this issue when trying to use Microsoft's Agentic Framework and Semantic Kernel libraries. Both of those routinely take over 30 seconds to import, spending most of that time importing openai. This renders the libraries useless for CLI or dev utilities and limits them to long-running applications.
This is a near-duplicate of Slow import times #2339, which was fixed, but has reappeared. It seems the new slowdown is caused by expansive internal typing libraries. These can be helpful for developing but are likely irrelevant to the consumer. f
To Reproduce
- (powershell)
Measure-Command { python.exe -c "import openai" } - (*nix)
time python.exe -c "import openai" python -X importtime -c "import openai"
Code snippets
OS
Windows 11, Ubuntu 24.04
Python version
Python v3.12.8 (on both Windows and Ubuntu)
Library version
openai v2.15.0 (on both Windows and Ubuntu)