You might also want to have a look at a numpy memmap viewed as a
recarray.

from numpy import dtype, memmap, recarray
# Define your record in the file, 4bytes for the real value,
# and 4 bytes for the imaginary (assuming Little Endian repr)
descriptor = dtype([("r", "<f4"), ("i", "<f4")])
# Now typecast a memap (a memory efficient array) onto the file in
read only mode
# Viewing it as a recarray means the attributes data.r and data.i are
acessible as
# ordinary numpy array
data = memmap(filename, dtype=descriptor, mode='r').view(recarray)
print "First 100 real values:", data.r[:100]

--Slaunger
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to