DMelt:IO/2 Java and Python IO
From HandWiki
Member
Java and Python IO
Native Java IO classes
Read Java IO tutorial. Below we show a simple example of how to use Java classes using Python/Jython syntax for IO:
from java.io import * fo=FileOutputStream('data.d') out=DataOutputStream(BufferedOutputStream( fo )) list=[1.,2.,3.,4.,5.] for a in list: out.writeFloat(a) out.close() fo.close()
Native Python IO
Read Python IO tutorial. Below we show an example of how to write a list of numbers using the Python class "pickle" for IO:
>>> import pickle >>> f=open('data.pic','w') >>> pickle.dump([1,2,3,4],f) >>> f.close()
I/O performance and benchmarks
Here we compare performance of the PFile and HFile classes for read and write mode. Benchmark results are given together with the code.