Improve performance by removing SHA
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- performance
调研方向
从 markdown2.py 开始阅读 _hash_html_block_sub 和 _hash_text,并跟踪它们生成的键如何在转换过程中保护和恢复内容。对当前的哈希开销进行性能分析,然后验证任何替换方案都能保持转换行为、避免键冲突,同时提升性能。
由索引模型根据 Issue 内容生成。
描述
The performance could be faster.
When I profile my blog build, about 60% of the time spent in markdown2.py is spent running SHA hashes.
Could you explain the logic of _hash_html_block_sub and _hash_text generally? Why are we even running SHA inside a markdown converter?
It looks like... this is some some of escape mechanism, maybe? Like we generate a key, replace the HTML with the key (so it doesn't look like HTML to some other stage of the parser that should ignore it), do some processing on the outer HTML, and finally replace all the keys with the original HTML?
That could be served just as well by generating a random string rather than a hash, if so?
Ex.
def _hash_text(s: str) -> str:
'md5-' + sha256(SECRET_SALT + s.encode("utf-8")).hexdigest()[32:]
could be replaced by the much faster
hex_digits = "0123456789abcdef"
def _hash_text(s: str) -> str:
'md5-' + ''.join(random.choice(hex_digits) for _ in range(32))
for a quick fix.
(Estimate says this will make markdown conversion 2.5X faster)
- 主要语言
- Python
- 星标
- 2.8k
- 派生
- 459
- 平均合并
- 2 天 14 小时
- 30 天内合并 PR
- 5
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
trentm/python-markdown2 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
trentm/python-markdown2#696 ·
-
难度 4/5 3-5 天 新手友好度 48/100
trentm/python-markdown2#726 ·
-
Bug
难度 4/5 3-5 天 新手友好度 55/100
trentm/python-markdown2#707 ·
-
Bug
难度 3/5 1-2 天 新手友好度 58/100
trentm/python-markdown2#688 · 4 条评论 ·
-
Bug
难度 3/5 1-2 天 新手友好度 58/100
trentm/python-markdown2#679 · 2 条评论 ·
查看 trentm/python-markdown2 的全部 Issue
相似的 Issue
-
correction metadata
难度 2/5 1-3 小时 新手友好度 68/100
acl-org/acl-anthology#10104 · 1 条评论 ·
维护者通常 1 天内回复
-
bug status/needs-triage
难度 2/5 1-3 小时 新手友好度 86/100
prowler-cloud/prowler#12885 · 1 条评论 ·
维护者通常 1 天内回复
-
Bug in GaussianTailProbabilityCalibrator: running_statistics=False still uses a windowed variance未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 88/100
selimfirat/pysad#107 ·
维护者通常 1 天内回复
-
bug ci-failure high priority
难度 1/5 1 小时以内 新手友好度 88/100
vllm-project/vllm-omni#8194 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复