You can test the actual function used with the @which macro. In the 1st
example
it calls into io.jl line 118 (at least as of version 0.3):
read{T}(s::IO, t::Type{T}, d1::Int, dims::Int...) =
read(s, t, tuple(d1,dims...))
this calls into io.jl line 123:
read{T}(s::IO, ::Type{T}, dims::Dims) = read!(s, Array(T, dims))
this calls into iostream.jl line 191:
function read!{T}(s::IOStream, a::Array{T})
if isbits(T)
nb = length(a)*sizeof(T)
if ccall(:ios_readall, Uint,
(Ptr{Void}, Ptr{Void}, Uint), s.ios, a, nb) < nb
throw(EOFError())
end
else
invoke(read!, (IO, Array), s, a)
end
a
end
*there is no loop!*
Also in the first version, the list comprehension in the loop is being
created each iteration.
maybe try using istead:
seek(position(stream)+4)
so you just move forward without creating a list.