<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">b) In MATLAB, arrays are used everywhere, also for small collections, where one would use tuples or lists in Python (e.g. multiple return values from a function). When I encounter an array in the original MATLAB code, I have to decide whether a tuple, a list, a numpy.ndarray or a PETSc.Vec/PETSc.Mat is appropriate. </blockquote>
<div><br></div><div>ndarray for numerical data, Python dicts and lists for more flexibility, PETSc Vecs and Mats if you need the PETSc API. Conversion between ndarray and PETSc Vecs is practically free, so I would keep them as numpy arrays for as long as possible (this is the strategy in pyclaw).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">One approach would be to use PETSc wherever the array can be larger than a typical tuple. Is there a performance penalty associated with using PETSc Vec/Mat for rather small arrays?<br>
</blockquote><div><br></div><div>I agree with Matt, no performance penalty here.</div><div><br></div><div>A </div></div></div>