Inplace operations on Data object copies

Asked by Lutz Gross

Why does the script

  from esys.escript import *
  from esys.finley import Rectangle
  print "x= ",x," y= ", y


  x = 2 and y = 2

and not x=2 and y=1 ?

Posted on behalf of Louise Olson-Kettle

Question information

English Edit question
esys-escript Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Lutz Gross (l-gross) said :

The statement y=x creates a shallow copy only. That means that the underlying data are not copied. Therefore an update of x will effect y. To make a deep copy you can use the copy method (which needs some revision) or - which is easier at this stage - use the statement y=x*1..

Revision history for this message
Joel Fenwick (j-fenwick1) said :

It is better to use the copy method now.

so to make y an independent copy of x use:


Can you help with this problem?

Provide an answer of your own, or ask Lutz Gross for more information if necessary.

To post a message you must log in.