optimize code for proxy handling of `urllib.request`
未關閉
還沒有人認領這個 Issue。
performance
stdlib
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Feature or enhancement
Proposal:
- the second loop of line starts from 1845 is duplicated from the first loop.
https://github.com/python/cpython/blob/2041a95e68ebf6d13f867e214ada28affa830669/Lib/urllib/request.py#L1817-L1853 - the registry access should be separated to a standalone function for cache, to be used by code like https://github.com/aio-libs/aiohttp/blob/e79b2d5df70a2644e81925cc49558962af91848d/aiohttp/client.py#L609-L617
https://github.com/python/cpython/blob/2041a95e68ebf6d13f867e214ada28affa830669/Lib/urllib/request.py#L2071-L2104 - the proxy setting from registry should be ignored when if proxies from environment exists? like the
proxy_bypass()
Should open a PR?
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
- gh-127767
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Lib/urllib/request.py 的 1817-1853 行和 2071-2104 行附近開始,然後比較連結的 aiohttp 代理處理。釐清目標是否包含對迴圈進行去重、抽出快取的 registry 存取,以及優先使用環境代理;完成的標準是已實作約定的代理行為,並由適當的 urllib.request 測試涵蓋。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- networking
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100