4 ms·
Could this ast.sprint ast.walk optimization make libCST or bandit faster? https://news.ycombinator.com/item?id=39111747 https://news.ycombinator.com/item?id=39
by westurner 4mo ago
Could this ast.sprint ast.walk optimization make libCST or bandit faster?
https://news.ycombinator.com/item?id=39111747 https://news.ycombinator.com/item?id=39111747
libCST: https://github.com/Instagram/LibCST https://github.com/Instagram/LibCST
bandit: https://github.com/PyCQA/bandit https://github.com/PyCQA/bandit
Links to codemod tools; "Baby Steps into Genetic Programming" https://news.ycombinator.com/item?id=43617655 https://news.ycombinator.com/item?id=43617655
- westurner 4mo agoAST: Abstract Syntax Tree FST: Full Syntax Tree CST: Concrete Syntax Tree Comment preservation is a feature
- adhami 4mo agoit's possible! although many of the constraints in this blog were because we wanted to work with ast module in Python. If we were allowed to create our own types, we can do so much better. I think ruff has an even faster walk by those standards. It seems bandit is using some decent optimizations already, looking at the `@test.checks("Call")` seems like they already captured some easy wins. The largest win honestly would be using the same ast.walk for multiple rules, which we also did, but not mentioned in the blog.
- westurner 4mo agoruff probably does. Docs for ruff_python_ast: https://docs.rs/littrs-ruff-python-ast/latest/ruff_python_ast/ https://docs.rs/littrs-ruff-python-ast/latest/ruff_python_as... src: ruff/crates/ruff_python_ast: https://github.com/astral-sh/ruff/tree/main/crates/ruff_python_ast https://github.com/astral-sh/ruff/tree/main/crates/ruff_pyth... ast.toml, generate.py, Cargo.toml, src/ https://github.com/astral-sh/ruff/blob/main/crates/ruff_python_ast/ast.toml https://github.com/astral-sh/ruff/blob/main/crates/ruff_pyth... Just rewrote docutils and myst-md-parser in rust with byte-for-byte equivalent output the other day; as westurner/dsport/src/docutilsrs and sphinxdocrs and so on. Pygmentsrs required fancy-regex because rust regex is linear. rstest and cargo-insta helped. PyCQA/docformatter https://github.com/PyCQA/docformatter https://github.com/PyCQA/docformatter and https://github.com/PyCQA/doc8 https://github.com/PyCQA/doc8 would be useful in rust, too. This from the other day: "A benchmark for catching when code doesn't do what its documentation claims"; docs fidelity evals https://news.ycombinator.com/item?id=48530786 https://news.ycombinator.com/item?id=48530786