In message <976599449.529443.29643.nullmailer / ev.netlab.zetabits.com> matz / zetabits.com writes: > |1) Are there packages/extensions/modules available > | for reading large amounts of binary data into arrays > | of structures? I know that binary data can be read > | a "char" at a time, but this is likely to be too > | slow. > > Read fixed sized string using IO#read then unpack it into integers > using String#unpack. For example: > > input = open(path_to_file, "r") > ary = [] > size_of_an_entry = (32*3+2*16)/8 > > while str = input.read(size_of_an_entry) > ary.push(str.unpack("NNNnn")) # assuming network byte order > end NOTE: If your application will run long time, you may experience a performance problem. This is caused by memory usage. Since reading data from IO always make a new object --- which is large in your application? --- garbaged old input will trigger GC too many time. You may need to write an extension which can reading data into a fixed buffer, like my toy program. <http://www.os.xaxon.ne.jp/~kjana/ruby/read_in.tar.gz> # Uh, it's not so proven since what I wanted was a runnable example # states my proposal :-P ....Well, fixed buffer reading was proposed # once on past.... -- kjana / os.xaxon.ne.jp December 12, 2000 Translators, traitors.