Skip to content

modify code generation to reduce whitespace #5225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gvwilson opened this issue Jun 10, 2025 · 0 comments
Open

modify code generation to reduce whitespace #5225

gvwilson opened this issue Jun 10, 2025 · 0 comments
Assignees
Labels
feature something new P1 needed for current cycle

Comments

@gvwilson
Copy link
Contributor

@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.load is 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).

@gvwilson gvwilson self-assigned this Jun 10, 2025
@gvwilson gvwilson added feature something new P1 needed for current cycle labels Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P1 needed for current cycle
Projects
None yet
Development

No branches or pull requests

1 participant