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

Specialize Iterators functions #390

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Oct 1, 2024

We may specialize Iterators.rest (and iterators.drop/Iterators.take analogously) to return AbstractFills. This ensures that we hit optimized methods that are defined for AbstractFills, instead of generic methods for iterators. As an example, the following works after this:

julia> allequal(Fill(4, ∞))
true

julia> @btime allequal($(Ref(Fill(4, ∞)))[]);
  8.403 ns (0 allocations: 0 bytes)

This also changes the behavior of slurping assignment a, b... = Fill(3, 4). After this, b is an AbstractFill as well, whereas previously, this used to be a Vector. This is achieved by specializing Base.rest.

julia> a, b... = Fill(3, 4)
4-element Fill{Int64}, with entries equal to 3

julia> b
3-element Fill{Int64}, with entries equal to 3

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.91%. Comparing base (6f61dc3) to head (aa3b3a3).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #390   +/-   ##
=======================================
  Coverage   99.91%   99.91%           
=======================================
  Files           8        8           
  Lines        1147     1155    +8     
=======================================
+ Hits         1146     1154    +8     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant