Hi,
While running my code with the 1.11 alpha 2 version of Julia, it broke due (I think) to a change introduced in Julia 1.11.
In the following code:
d = IOBuffer("hello")
dd = d.data
dd
is a Vector{UInt8} in julia 1.10 but is a Memory{UInt8} in 1.11.
Which broke my code because there is no insert!
function for Memory{UInt8}
1/ the Julia documentation says it is “One-dimensional dense array with element of type T.” What is the difference with Vector{T} ? And in which case should I use Memory?
2/ is there an easy way to convert Memory to Vector?
3/ is there a plan to add an insert function for Memory?
Thank you
1 Like
In general, the fields of objects in Julia are considered internal. So, there is no guarantee that fields of objects don’t change in minor versions. I’ll admit it’s not at all clear to users of Julia what is and isn’t internal, though. To prevent issues like this in the future, I recommend structuring your code so you don’t need to access individual fields of types that are not your own. Anyway, to your questions:
-
Memory is more low-level, as it doesn’t support multiple axes (dimensions), and it can’t dynamically change size. You can think of a Vector
as a Memory plus to integers - an offset and a length. If you know that you don’t need to resize a vector, Memory
removes a small amount of overhead
-
collect(mem)
to create a new Array copying the elements, and wrap
to create a new array backed by the memory.
-
That’s not possible, because the whole idea of Memory is to be lower level, which is possibly precisely because it can’t change size. So that can’t be done.
15 Likes