MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Why does Through unpack?

  • To: mathgroup at
  • Subject: [mg125587] Why does Through unpack?
  • From: Szabolcs <szhorvat at>
  • Date: Tue, 20 Mar 2012 02:20:32 -0500 (EST)
  • Delivered-to:

Consider the following example:


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.


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.

  • Prev by Date: Re: More powerful text processing
  • Next by Date: Re: Using Mathematica to typeset books
  • Previous by thread: Re: Different answers in mathematica and my calculator.
  • Next by thread: Re: Why does Through unpack?