[petsc-dev] [petsc4py] Vec.getArray()

Jed Brown jed at 59A2.org
Sat Aug 28 06:43:34 CDT 2010


On Fri, 27 Aug 2010 15:14:02 -0300, Lisandro Dalcin <dalcinl at gmail.com> wrote:
> I cannot figure out how to implement a copy-free and safe
> VecGetArray()/VecRestoreArray() pattern in Python (not even by using
> the 'with' statement, it leaks the target variable!!!!).

What exactly leaks?


I envision

  with X.getArray() as x:
    x[0] = 1.

and

  with Vec.getArrays(X,Y,Z) as (x,y,z):
    x = y + z  # Numpy vectorized addition

instead of cascading with statements

Jed



More information about the petsc-dev mailing list