title: Using numpy.bmat with numba
body: <p>I am trying to use np.bmat in my numba-optimized python program. To do so, I have to manually define a jitted function bmat since the native one from numpy is not supported:</p>
  
  <pre class="lang-py prettyprint-override"><code>@njit
  def _bmat_2d(matrices):
      arr_rows = []
      for row in matrices:
          arr_rows.append(np.concatenate(row, axis=-1))
      return np.array(np.concatenate(arr_rows, axis=0))
  </code></pre>
  
  <p>(this code is more or less a simplified copy of the one from numpy)</p>
  
  <p>However:</p>
  
  <ol>
  <li>numba only accepts tuples in input of np.concatenate [1]</li>
  <li>numba is very bad at casting arbitrary list to tuples [2]</li>
  </ol>
  
  <p>Do you have any idea for this ?</p>
  
  <p>Refs:</p>
  
  <ul>
  <li>[1] <a href="https://github.com/numba/numba/issues/2787" rel="nofollow noreferrer">https://github.com/numba/numba/issues/2787</a></li>
  <li>[2] <a href="https://github.com/numba/numba/issues/2771" rel="nofollow noreferrer">https://github.com/numba/numba/issues/2771</a></li>
  </ul>