Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9163 > unrolled thread

Why does Through unpack?

Started bySzabolcs <szhorvat@gmail.com>
First post2012-03-20 07:21 +0000
Last post2012-03-20 07:21 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Why does Through unpack? Szabolcs <szhorvat@gmail.com> - 2012-03-20 07:21 +0000

#9163 — Why does Through unpack?

FromSzabolcs <szhorvat@gmail.com>
Date2012-03-20 07:21 +0000
SubjectWhy does Through unpack?
Message-ID<jk9b6m$blb$1@smc.vnet.net>
Consider the following example:

On["Packing"]

dat = RandomInteger[1*^7, {5000000, 2}];

Max /@ Transpose[dat]; // AsboluteTiming

Note that the array is only unpacked to level 1, so Max is fast.

Now let's get both the Min and the Max:

Through /@ {Min, Max} /@ Transpose[dat]; // AbsoluteTiming

Now the full array is unpacked, significantly hurting performance.

Question:

Why is it necessary to unpack the array when using Through?  Here it doesn't seem to be.  Is it a design decision that Through unpacks, or is it an over sight?  Through does not touch the function argument (it only affects the head), I don't see why it would need to unpack it.

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web