Regarding serialization, they are likely referring to using pickle or marshall to save the numpy object to a file. The two scripts below show how this works.
- The parent.py script creates a simply numpy array and "pickles" (serializes) it to a file.
- The file path is passed to the child script to start a subprocess.
- The child script "unpickles" (de-serializes) the array, modifies it, then re-pickles it.
- The parent script unpickles the modified array and prints the result.
# parent.py
import numpy, pickle, os, subprocess, sys
colArray = numpy.array([1,2,3])
strOutputFile = os.path.join(os.getenv('TEMP'), "array.pkl")
pickle.dump(colArray, open(strOutputFile, 'wb'))
print colArray
strChildScript = r"C:\Temp\child.py"
intReturnCode = subprocess.call([os.path.join(sys.prefix, "python.exe"), strChildScript, strOutputFile])
colNewArray = pickle.load(open(strOutputFile, 'rb'))
print colNewArray
# child.py
import numpy, pickle, sys
strOutputFile = sys.argv[1]
colArray = pickle.load(open(strOutputFile, 'rb'))
colArray2 = numpy.array([4,5,6])
colArray = numpy.vstack((colArray, colArray2))
pickle.dump(colArray, open(strOutputFile, 'wb'))