Avoid array copies in Matlab and Python
More convenient array broadcasting was added to Matlab years ago, removing the need for bsxfun. Python Numpy has even more advanced array indexing and broadcasting features to conserve memory, speeding computations.
When translating between Matlab and Python, don’t simply replace Matlab repmat with numpy.tile. It may be possible to use numpy.newaxis or numpy.broadcast_to for O(1) speed and memory saving.