anthropics / anthropics/anthropic-sdk-python

Slow imports

未關閉
#1,211 11 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
sdk
主要語言
Python
星號
3.9k
分支
853
平均合併
1 天 18 小時
30 天內合併 PR
11

描述

# 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!

```sh
python3 -X importtime -c "import anthropic"

...
import time: 66 | 69232 | anthropic.lib.tools
...
import time: 506 | 116232 | anthropic.types
...
import time: 329 | 209401 | anthropic
```

```sh
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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。