Re:Python Patterns - An Optimization Anecdote
by nene on Tuesday November 02, 2010 @10:27AM
(#1860516)
Found an answer.
The problem is that String.fromCharCode takes multiple arguments and Array.map also passes multiple arguments to the callback, therefore the equivalent of numbers.map(String.fromCharCode) is actually:
numbers.map(function(x, y, z){return String.fromCharCode(x, y, z);})
Which of course is slower as the end result will actually be array with longer strings in it.
The problem is that String.fromCharCode takes multiple arguments and Array.map also passes multiple arguments to the callback, therefore the equivalent of numbers.map(String.fromCharCode) is actually:
Which of course is slower as the end result will actually be array with longer strings in it.