improve performance of python broadcast