-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Remove dynamic dispatch from (General)LazyBufferCache #93
Conversation
sizemap::F | ||
LazyBufferCache(f::F = identity) where {F <: Function} = new{F}(Dict(), f) # start with empty dict | ||
end | ||
|
||
# override the [] method | ||
function Base.getindex(b::LazyBufferCache, u::T) where {T <: AbstractArray} | ||
s = b.sizemap(size(u)) # required buffer size | ||
buf = get!(b.bufs, (T, s)) do | ||
get!(b.bufs, (T, s)) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that change actually make a difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at all. That is just for stylistic consistency with the rest of the file.
may not be even measurable. The upside of `LazyBufferCache` is that the user does | ||
not have to worry about potential issues with chunk sizes and such: `LazyBufferCache` | ||
is much easier! | ||
Note that `LazyBufferCache` is type-stable and contains no dynamic dispatch. This gives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't it have an internal dynamic dispatch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow that's pretty incredible. Julia used to not be able to omit that.
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.
Additional context
Add any other context about the problem here.