MathGroup Archive 2008

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

Search the Archive

Cost of Composition vs Pure Function

The speed difference between these two evaluations seems odd,
considering they are effectively the same thing:

m = RandomReal[{0, 1}, {10, 1000, 1000}];

Total[Total[#]]& /@ m; // Timing => 0.14 sec

Composition[Total, Total] /@ m; // Timing => 0.983 sec

Other than the Identity and Inverse Function transformation, where is
this overhead coming from?


  • Prev by Date: Re: Basic programming
  • Next by Date: How to pass a function to a function?
  • Previous by thread: Re: Mathematica 7 is now available
  • Next by thread: Re: Cost of Composition vs Pure Function