Monthly Archives: April 2010

Cloning arrays in python

For single dimensions arrays:

a2 = a[:]
non-scalers within array will be copied as references. Does the same thing as copy.copy()

For multi dimension arrays:

import copy
a2 = copy.deepcopy(a)
non-scalers within array will be cloned as new objects