optimize code for proxy handling of `urllib.request`
未关闭
还没有人认领这个 Issue。
performance
stdlib
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- 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