kislyuk / yq

Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
https://kislyuk.github.io/yq/
Apache License 2.0
2.57k stars 82 forks source link

performance is very slow #123

Closed dudicoco closed 2 years ago

dudicoco commented 3 years ago

When processing a lot of files with yq, the performance impact is noticeable:

for f in $files; do
  yq '.' $file
done

It takes around 15 seconds to process 650 files, while jq takes around 1-2 seconds.

SethMMorton commented 3 years ago

Do you see the same magnitude of slowness if you do e.g.

yq '.' "${files[@]}"

?

I wonder if you are just measuring the Python startup time instead of the tool performance.

kislyuk commented 2 years ago

yq is subject to performance limitations of Python and PyYAML (in plain Python parsing mode, since yq makes a number of customizations to the parsing process). There are no plans to dedicate resources to improving performance beyond what will be available in future versions of Python. As @SethMMorton correctly points out, streaming multiple documents (separated by ---) can amortize the startup time. PRs to improve performance are welcome.