9
$\begingroup$

See this example, a function has Listable attributes often more efficient than Map,but why is this one is an exception?

With[{n = 6},
   IntegerDigits[Range[10^(n - 1), 10^n - 1]]
   ] // Hash // AbsoluteTiming
(*{1.573090, 756716557}*)

With[{n = 6},
   IntegerDigits /@ Range[10^(n - 1), 10^n - 1]
   ] // Hash // AbsoluteTiming
(*{0.202012, 756716557}*)
$\endgroup$
9
$\begingroup$

Map is autocompiling. If you turn autocompilation off, i.e., if you set

SetSystemOptions[
  "CompileOptions" -> "MapCompileLength" -> Infinity];

then the timings are the same.

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ But you artificially made Map slower. $\endgroup$ – Sasha Aug 19 '13 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.