Skip to content
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

Lazier core filters #131

Merged
merged 7 commits into from
Jan 9, 2024
Merged

Lazier core filters #131

merged 7 commits into from
Jan 9, 2024

Conversation

01mf02
Copy link
Owner

@01mf02 01mf02 commented Nov 23, 2023

This PR delays the execution of many core filters.
For example, before this change, the filter 1, debug printed:

[DEBUG] null
1
null

After this change, this prints:

1
[DEBUG] null
null

This is more consistent with jq, which yields:

1
["DEBUG:",null]
null

In some cases, this makes filters terminate which did not terminate before. For example,

[0, 1] | first(1, sort_by(repeat(0)))

yielded no single output before, because sort_by was executed before 1 was yielded. With this PR, jaq yields 1 (just like jq).

Previously, also the last/1 filter was executed strictly. With this PR, it is implemented by definition in a naturally lazy way.
This makes the bf-fib benchmark a bit slower (runtime decreases from 414.8 ms to 485.3 ms), but it remains still a lot faster than in jq or gojq. This also makes the evaluation fairer, because jq also implements last/1 by definition.

@01mf02 01mf02 merged commit d2fda4d into main Jan 9, 2024
1 check passed
@01mf02 01mf02 deleted the core-lazy branch January 9, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant