What I know:
PackedArray
is documented (to some extent) in "Developer Utilities Package",RawArray
is just mentioned inRaster3D
andImageApply
,RawArray
supportsByte
,SignedInteger8/16/32
,Bit16
,Real32
,Real
andComplex128
as entries, whilePackedArray
onlyInteger
,Real
andComplex
(128),PackedArray
displays as a list butRawArray
as (somewhat of) a skeleton.
What I do not understand is why there are two of them. Why not just stick with the one that supports more entry types and display it as skeleton if and only if it is too long?
Also, how does ByteArray
fit into the picture?
Edit: You can create a PackedArray
using:
ap = Developer`ToPackedArray[{1, 2, 3}]
(* {1,2,3} *)
Developer`PackedArrayQ[ap]
(* True *)
Developer`PackedArrayForm[ap]
(* PackedArray[Integer, <3>] *)
(Note that there is in fact no PackedArray
command, the head of the last output expression is a string.)
You can create a RawArray
using:
ar = Developer`AllocateRawArray["Byte", {2, 2}]
(* RawArray[Byte, <2,2>] *)
Developer`RawArrayQ[ar]
(* True *)
Developer`RawArrayType[ar]
(* Byte *)
(ditto about RawArray
).
You can create a ByteArray
directly:
ab = ByteArray[{1,2,3}]
(* ByteArray[<3>] *)
ByteArrayQ[ab]
(* True *)
All the cross-tests (e.g., RawArrayQ
done on ab
) return False
.
ByteCount
both packed and raw arrays use at least 8 bytes per value, even with the "Byte" type explicitly called out. ByteArray uses the expected one byte per value. The raw array seems to be always exactly 96 bytes bigger than the packed array. $\endgroup$PackedArray
can't use bytes, 8 bytes is the word size on a 64-bit machine so that makes sense.RawArray
works well for me:ar = Developer`AllocateRawArray["Byte", {10000}]; ByteCount[ar]
gives just a little over 10000. It's 176 rather than 96 bytes of overhead on my computer. $\endgroup$AllocateRawArray["Byte", *biglist* ]
which is invalid so just getting the size of the list. $\endgroup$*biglist*
you should use a dimension specification, e.g.{40,50}
is a40
by50
matrix. $\endgroup$ByteCount
andMemoryInUse
indicate hardly any memory usage after "allocating" a large array. $\endgroup$