Lazy Imports & Fast Startup
PraisonAI Agents v0.5.0+ uses lazy imports to dramatically reduce startup time and memory usage. Heavy dependencies likelitellm, requests, and chromadb are only loaded when actually needed.
Performance Benefits
| Metric | Before | After | Improvement |
|---|---|---|---|
| Import Time | 820ms | 18ms | 97.8% faster |
| Memory Usage | 93.3MB | 33.0MB | 64.6% reduction |
How It Works
Lazy Module Loading
Core modules are loaded on-demand using Python’s__getattr__ mechanism:
Heavy Dependencies
The following dependencies are NOT loaded at import time:- litellm - Only loaded when LLM calls are made
- requests - Only loaded when HTTP calls are needed
- chromadb - Only loaded when vector stores are used
- mem0 - Only loaded when memory features are used
Verifying Lazy Imports
You can verify lazy imports are working:Configuration
Lazy imports are enabled by default. You can check the configuration:Best Practices
- Import at module level - Imports are fast, so import at the top of your file
- Use specific imports - Import only what you need
- Avoid star imports -
from praisonaiagents import *loads everything

