Why is Numpy much faster at creating a Zero array compared to replacing the values of an existing array with zeros?

The reason is that the array is not filled in memory on mainstream operating systems (Windows, Linux and MaxOS). Numpy allocates a zero-filled array by requesting to the operating systems (OS) a zero-filled area in virtual memory. This area is not directly mapping in physical RAM. The mapping and zero-initialization is generally done lazily by … Read more

Lodash create collection from duplicate object keys

Use _.groupBy and then _.map the resulting object to an array of objects. var newOutput = _(output) .groupBy(‘article’) .map(function(v, k){ return { article: k, titles: _.map(v, ‘title’) } }) .value(); var output = [{“article”:”BlahBlah”,”title”:”Another blah”},{“article”:”BlahBlah”,”title”:”Return of the blah”},{“article”:”BlahBlah2″,”title”:”The blah strikes back”},{“article”:”BlahBlah2″,”title”:”The blahfather”}]; let newOutput = _(output) .groupBy(‘article’) .map(function(v, k){ return { article: k, titles: _.map(v, … Read more