python - saving numpy array to a file (smallest size possible)
numpy.ndarray.tofile and numpy.fromfile are useful for direct binary output/input from python.  std::ostream::write std::istream::read are useful for binary output/input in c++.
You should be careful about endianess if the data are transferred from one machine to another.
Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt.  The numpy array contains only floats.  I then read the file in one row at a time in a separate C++ program.
What I would like to do is find a way to accomplish this same task, changing my code as little as possible such that I can decrease the size of the file I am passing between the two programs.  
I found that I can use numpy.savetxt to save to a compressed .gz file instead of a text file.  This lowers the file size from ~2MB to ~100kB.  
Is there a better way to do this?  Could I, perhaps, write the numpy array in binary to the file to save space?  If so, how would I do this so that I can still read it into the C++ program?
Thank you for the help.  I appreciate any guidance I can get.
EDIT:
There are a lot of zeros (probably 70% of the values in the numpy array are 0.0000) I am not sure of how I can somehow exploit this though and generate a tiny file that my c++ program can read in