⚡ Solution Summary
- Importing stripe library adds 500ms to startup time
- Lazy loading parts of the library may help
- Consider using a central get_stripe_client() function
- Upgrade to the latest version for potential improvements
- Monitor memory usage and cold start implications.
### Describe the bug
I looked around, searched the issues and even googled. Surprised this hasn't come up.
Just importing the library adds 500ms to startup time. There's got to be a way to lazy load parts.
This is on a top of the line Mac with SSD.
### To Reproduce
```python
# Takes about 20 ms
time python -c "print('ok')";
# Takes bout 500ms
time python -c "print('ok'); import stripe"
```
### Expected behavior
For serverless setups, startup time is pretty important.
Even for local development, django's runserver or uvicorn's reload are both much slower with imports like these.
Of course you can do the import locally everywhere stripe is used, but this can be problematic.
At the very least, some guidance in the docs on how to do imports and have a lazy-loaded client would help. Something like a central `get_stripe_client() -> Stripe` or the like. And cover thread-safety in here.
### Code snippets
_No response_
### OS
macOS
### Language version
3.12.1
### Library version
11.3.0
### API version
2020-08-27
### Additional context
_No response_
Discussion & Fixes