Thanks for the suggestion! I changed: print Marshal.dump(dict) to: Marshal.dump(dict, STDOUT) and it runs fine now. Interesting thing I noticed before when I was doing it the slow way - 1000 entries took 1 second, but 2000 entries took 7.7 seconds. So the time required seemed to scale up exponentially.