timing
Is it really ok that it takes 209ms to import even a single type from this package?
This feels like the perfect task for Claude Code?!
I have no background in the best way to solve this issue, I just know this feels wrong for such a central dependency. And common, let's be honest, this is a glorified HTTP client.
This destroys downstream performance in packages like langchain_anthropic which wind up taking 300ms+ for imports alone, just to make a simple http call to generate a completion!
python3 -X importtime -c "import anthropic"
...
import time: 66 | 69232 | anthropic.lib.tools
...
import time: 506 | 116232 | anthropic.types
...
import time: 329 | 209401 | anthropic
python3 -X importtime -c "from anthropic.types.image_block_param import ImageBlockParam"
...
import time: 313 | 208162 | anthropic
import time: 7 | 208169 | anthropic.types
import time: 10 | 208178 | anthropic.types.image_block_param
I'd hate to think that just because it's python it's ok to ignore optimizations... but, perhaps my expectations are miscalibrated, I'm open to that possibility. Am I crazy?
Claude seems to agree
I've got Claude working on some ideas for me! I don't have time to do this myself, but, Claude is killing it with perf profiling and I bet will find the spots we can get some big wins.
Gotta tame the explosion of types and importing all of them on every import basically
timing
Is it really ok that it takes 209ms to import even a single type from this package?
This feels like the perfect task for Claude Code?!
I have no background in the best way to solve this issue, I just know this feels wrong for such a central dependency. And common, let's be honest, this is a glorified HTTP client.
This destroys downstream performance in packages like
langchain_anthropicwhich wind up taking 300ms+ for imports alone, just to make a simple http call to generate a completion!I'd hate to think that just because it's python it's ok to ignore optimizations... but, perhaps my expectations are miscalibrated, I'm open to that possibility. Am I crazy?
Claude seems to agree
I've got Claude working on some ideas for me! I don't have time to do this myself, but, Claude is killing it with perf profiling and I bet will find the spots we can get some big wins.
Gotta tame the explosion of types and importing all of them on every import basically