mmap?
Fredrik Lundh
effbot at telia.com
Mon Oct 23 14:25:50 EDT 2000
seung-won hwang wrote:
> Hi, thanks for your answer. However, I think mmap is only for mutable
> string. Is there any other way to save/load data structure on memory
> to file using Python? Your answer would be very helpful to me!
if the file format doesn't matter, use "pickle" or "marshal"
modules:
mydata = ...
file = open("myfile.dat", "wb")
pickle.dump(mydata, file)
file.close()
...
file = open("myfile.dat", "rb")
data = pickle.load(file)
file.close()
to write data in a given binary format (e.g. if you want to
read it back from a C program), use the "struct" module.
for more info, see the library reference.
</F>
More information about the Python-list
mailing list