Import is toooooo heavy | 导入太重了 应当解耦
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
- Domain
- developer-experience
Research direction
Start by reading lark_oapi/init.py and tracing which classes and services it imports when users run import lark_oapi. Measure import time and memory, then identify how the Client or individual services could be loaded more lazily. Done means importing the package no longer eagerly loads unrelated services while the requested IM service remains usable.
Written by the indexing model from the issue text.
Description
我在使用 lark_oapi 时,感受到一个比较明显的问题:顶层导入太“重”了。
从 https://github.com/larksuite/oapi-sdk-python/blob/v2_main/lark_oapi/__init__.py 看,即使用户只想用到发消息的IM service,也会把一堆类都拉进来,不仅消耗内存,还占用很长的导入时间,初始化时间久。
希望:Client 或各 service 能更接近懒加载;避免 import lark_oapi 就触发一大串导入 (当然也会导致巨大的内存开销)
- Dominant language
- Python
- Stars
- 559
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from larksuite/oapi-sdk-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
larksuite/oapi-sdk-python#163 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
larksuite/oapi-sdk-python#162 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
larksuite/oapi-sdk-python#161 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
larksuite/oapi-sdk-python#160 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
larksuite/oapi-sdk-python#159 ·
All issues in larksuite/oapi-sdk-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
gradio-app/gradio#13895 ·
Maintainers usually reply within 1 day
-
build-error
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spack/spack-packages#6713 ·
Maintainers usually reply within 1 day
-
Use issue templatesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ActivityWatch/activitywatch#1464 · 1 reaction ·
Maintainers usually reply within 1 day
-
[Bug]: The ckg tool drops the return type of every decorated Python method in class search resultsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bytedance/trae-agent#483 ·
Maintainers usually reply within 1 day