Skip to main content
added 76 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Bug introduced in 5.2 or earlier and fixed in 10.1.0


This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be possible to give a definitive and exhaustive answer to "why" questions but such topics have often been fruitful.


Why does list assignment of the form {a, b, c} = tensor where tensor is packed result in unpacked values for a, b, and c?

To illustrate:

packedQ = Developer`PackedArrayQ;

tensor = RandomReal[99, {3, 5, 7}];

tensor // packedQ

True

{a, b, c} = tensor;

packedQ /@ {a, b, c}

{False, False, False}

It is possible to make the assignments without unpacking the sub-arrays of tensor by manually unpacking the outer list using Apply:

{a, b, c} = List @@ tensor;

packedQ /@ {a, b, c}

{True, True, True}

Why doesn't Set operate like this by default?

That is, why doesn't Set only unpack the right-hand-side as far as necessary, to the level of the left-hand-side?

This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be possible to give a definitive and exhaustive answer to "why" questions but such topics have often been fruitful.


Why does list assignment of the form {a, b, c} = tensor where tensor is packed result in unpacked values for a, b, and c?

To illustrate:

packedQ = Developer`PackedArrayQ;

tensor = RandomReal[99, {3, 5, 7}];

tensor // packedQ

True

{a, b, c} = tensor;

packedQ /@ {a, b, c}

{False, False, False}

It is possible to make the assignments without unpacking the sub-arrays of tensor by manually unpacking the outer list using Apply:

{a, b, c} = List @@ tensor;

packedQ /@ {a, b, c}

{True, True, True}

Why doesn't Set operate like this by default?

That is, why doesn't Set only unpack the right-hand-side as far as necessary, to the level of the left-hand-side?

Bug introduced in 5.2 or earlier and fixed in 10.1.0


This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be possible to give a definitive and exhaustive answer to "why" questions but such topics have often been fruitful.


Why does list assignment of the form {a, b, c} = tensor where tensor is packed result in unpacked values for a, b, and c?

To illustrate:

packedQ = Developer`PackedArrayQ;

tensor = RandomReal[99, {3, 5, 7}];

tensor // packedQ

True

{a, b, c} = tensor;

packedQ /@ {a, b, c}

{False, False, False}

It is possible to make the assignments without unpacking the sub-arrays of tensor by manually unpacking the outer list using Apply:

{a, b, c} = List @@ tensor;

packedQ /@ {a, b, c}

{True, True, True}

Why doesn't Set operate like this by default?

That is, why doesn't Set only unpack the right-hand-side as far as necessary, to the level of the left-hand-side?

edited tags
Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
added 119 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

Why does list assignment to anwith a packed array result in unpacked values?

This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be possible to give a definitive and exhaustive answer to "why" questions but such topics have often been fruitful.


Why does list assignment of the form {a, b, c} = tensor where tensor is packed result in unpacked values for a, b, and c?

To illustrate:

packedQ = Developer`PackedArrayQ;

tensor = RandomReal[99, {3, 5, 7}];

tensor // packedQ

True

{a, b, c} = tensor;

packedQ /@ {a, b, c}

{False, False, False}

It is possible to make the assignments without unpacking the sub-arrays of tensor by manually unpacking the outer list using Apply:

{a, b, c} = List @@ tensor;

packedQ /@ {a, b, c}

{True, True, True}

Why doesn't Set operate like this by default?

That is, why doesn't Set only unpack the right-hand-side as far as necessary, to the level of the left-hand-side?

Why does list assignment to an array result in unpacked values?

This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be possible to give a definitive and exhaustive answer to "why" questions but such topics have often been fruitful.


Why does list assignment of the form {a, b, c} = tensor where tensor is packed result in unpacked values for a, b, and c?

To illustrate:

packedQ = Developer`PackedArrayQ;

tensor = RandomReal[99, {3, 5, 7}];

tensor // packedQ

True

{a, b, c} = tensor;

packedQ /@ {a, b, c}

{False, False, False}

It is possible to make the assignments without unpacking the sub-arrays of tensor by manually unpacking the outer list using Apply:

{a, b, c} = List @@ tensor;

packedQ /@ {a, b, c}

{True, True, True}

Why doesn't Set operate like this by default?

Why does list assignment with a packed array result in unpacked values?

This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be possible to give a definitive and exhaustive answer to "why" questions but such topics have often been fruitful.


Why does list assignment of the form {a, b, c} = tensor where tensor is packed result in unpacked values for a, b, and c?

To illustrate:

packedQ = Developer`PackedArrayQ;

tensor = RandomReal[99, {3, 5, 7}];

tensor // packedQ

True

{a, b, c} = tensor;

packedQ /@ {a, b, c}

{False, False, False}

It is possible to make the assignments without unpacking the sub-arrays of tensor by manually unpacking the outer list using Apply:

{a, b, c} = List @@ tensor;

packedQ /@ {a, b, c}

{True, True, True}

Why doesn't Set operate like this by default?

That is, why doesn't Set only unpack the right-hand-side as far as necessary, to the level of the left-hand-side?

Tweeted twitter.com/#!/StackMma/status/359320701003513857
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
Loading