01mf02 / jaq

A jq clone focussed on correctness, speed, and simplicity
MIT License
2.7k stars 67 forks source link

Generate objects lazily & remove itertools dependency #119

Closed 01mf02 closed 11 months ago

01mf02 commented 11 months ago

This PR makes evaluation of object keys/values lazy.

Previously, the following filter would never yield a single result:

'{("a", "b"): (0 | recurse(.+1)), ("c", "d"): 2}'

Now, it generates an infinite stream of objects, just like jq.

How's performance? Let's test it with the following filter:

limit(1000000; {("a", "b"): (0 | recurse(.+1)), ("c", "d"): 2}) | empty

jq 1.7 takes 1.1 seconds, whereas jaq takes only 0.5 seconds! :)

As a bonus, this also eliminates the dependency of jaq-interpret on itertools.