0

In Mathematica, there is a concept called packed array.

In[1]:= ClearAll[A, B, L1, L2, L3, L4];
A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 
   19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
B = Range[30];
L1 = Developer`FromPackedArray[A];
L2 = Developer`ToPackedArray[A];
L3 = Developer`FromPackedArray[B];
L4 = Developer`ToPackedArray[B];

In[2]:= A === B === L1 === L2 === L3 === L4

Out[2]= True

In[3]:= {ByteCount[A], ByteCount[B], ByteCount[L1], ByteCount[L2], ByteCount[L3], ByteCount[L4]}

Out[3]= {768, 360, 768, 360, 768, 360}

  1. For what Mathematica objects, does the concept of 'packed/unpacked' exist? (only for List?)

  2. We can define compression method (7z/zip/tar/...) or compression level (store/very fast/fast/normal...) for archive utility like 7-zip. Likewise, are there various degrees/methods/kinds of packing in Mathematica? Or it is just 'packed or unpacked' like '0 or 1'.

  3. How can we check/verify a Mathematica object is packed/unpacked ? (+ inspect the degree/methods/kinds)

I have more questions :

  1. Does Developer`FromPackedArray do nothing for unpacked array ?
  2. Does Developer`ToPackedArray do nothing for packed array ?
  3. Are there any option for Developer`FromPackedArray/Developer`ToPackedArray ?
  4. Are there any other function that can change the state of packed/unpacked (or degrees/methods/kinds) ?
imida k
  • 4,285
  • 9
  • 17

0 Answers0