Hello, I've been working on some unsafe fast I/O procedures for my own use, and I thought I'd make them an extension, if more people would like to use them.
The "fast-io" extension would have these procedures: Implemented and tested: - write-fixnum, read-fixnum - write-flonum, read-flonum - write-one-char, read-one-char (I don't know if the names are OK; I didn't want them to conflict with R5RS procedures) Implemented, not tested: - write-complex, read-complex Planned but not yet implemented: - write-string - read-string-n - read-string-until (reads until a delimiter is found) - read-string-between (ignores characters until left delimiter, then reads until right delimiter) All of these are implemented using (as little as possible) foreign-lambda* with some inline calls to fprintf, fscanf, and fgetc. The only kind of error checked for is the return from the C functions (and if, for example, fscanf fails to read, then a (configurable) scheme error procedure is called). The two last string-reading procedures will be triple-checked for security. :-) Why: For everyday use, I really think this isn't necessary. But if you need (as I think I'll need) to read and write very large amounts of numbers from/to files, several times. Then this becomes useful. If you *know* that your file only has fixnums or flonums (written by your program), then you can use these procedures -- so there's no need to make the program go checking if it looks like an exact or inexact number, or as a string, or whatever. Just tell it to "read an integer number!") If there is interest, it's already packaged as an egg (installed on my machine). The speedup I got is on the following table: scheme fast-io speedup ------------------------------------------- write fixnum 14.602 5.303 2.7535 read fixnum 58.208 11.706 4.9725 write flonum 37.003 21.647 1.7094 read flonum 100.367 15.626 6.4231 ------------------------------------------- These are for reading and writing values from/to large files. I'll include the benchmarking code with the egg, as well as tests. Thanks, J. _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users