I think it would be nice to have a non-allocating, fast read(io, Float64)
(e.g.) in Base.
I’m aware of read!(s::IO, x::Ref{T}) where {T}
, but the Ref
is still a little cumbersome to work with, because at least right now (on master) creating the Ref
allocates (which is why read(io, Float64)
allocates). So in order to achieve zero allocation, you have to have a cache that contains the pre-allocated Ref
.
In the past, I’ve used https://github.com/BioJulia/BufferedStreams.jl to get a read(io, ::Type{Float64})
that doesn’t allocate:
i.e. what ScottPJones
was talking about. Maybe having this kind of thing in Base for certain frequently-used bitstypes would be good. Or maybe we just wait for compiler improvements that elide the Ref
allocation.