Qustion about struct.unpack

OhKyu Yoon okyoon at stanford.edu
Mon Apr 30 03:45:22 EDT 2007


Hi!
I have a really long binary file that I want to read.
The way I am doing it now is:

for i in xrange(N):  # N is about 10,000,000
    time = struct.unpack('=HHHH', infile.read(8))
    # do something
    tdc = struct.unpack('=LiLiLiLi',self.lmf.read(32))
    # do something

Each loop takes about 0.2 ms in my computer, which means the whole for loop 
takes 2000 seconds.
I would like it to run faster.
Do you have any suggestions?
Thank you very much.

OhKyu 




More information about the Python-list mailing list