modify code generation to reduce whitespace
未关闭
还没有人认领这个 Issue。
feature
P1
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
@alexcjohnson wrote:
- We should be able to reduce the whitespace significantly, to make the file smaller. Could even collapse it to a single line, I'm not sure there's much value keeping it human-readable, but maybe @emilykl has opinions about this. If we really want to optimize file size we could also change its structure a bit - like if every entry is a dict
{params, superclass}this could be converted to a length-2 list. But the whitespace is the biggest piece of this. json.loadis pretty fast, ~41ms on my computer. But it's even faster if we just make this a Python file. In my quick test I just added:
true=True
false=False
null=None
v =
to the beginning of the file to convert the JSON to Python, and then from validators._validators import v took only ~25ms. (If we do this for real we should be able to tweak the json.dump to output Python in the first place so we don't need to alias true, false, and null).
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
该 issue 指向生成的 validators._validators 数据和 JSON 生成路径,但没有指出仓库文件或测试。首先定位生成器和生成的模块,然后将当前的 json.dump 输出与提议的紧凑表示或 Python 表示进行比较。完成的标准是生成的文件更小,同时其数据仍可加载,并且现有的 validator 行为得到保留。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- build-system, performance
- Issue 类型
- 重构
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100