On Thursday, June 9, 2016 at 6:36:35 PM UTC-4, Arch Robison wrote
>
> Yes, I know if I declare x with a concrete type such as Int, the code will
> do blazingly fast. But I was poking around to see if declaring it with an
> abstract type narrower than Any would help.
>
I think the other piece of standard advice in situations like these is to
make a parametric type instead of a single type with abstract fields, so
type NotAsSlow{T<:Unsigned}
x::T
end
for i=1:3
@time flog(NotAsSlow(UInt64(42)))
end
0.014765 seconds (8.38 k allocations: 342.502 KB)
0.000945 seconds (6 allocations: 192 bytes)
0.001423 seconds (6 allocations: 192 bytes)