-------- Original-Nachricht -------- > Datum: Sun, 8 Jun 2008 05:53:49 +0900 > Von: progcat / comcast.net > An: ruby-talk / ruby-lang.org > Betreff: storing values for later use > I have a group of expensive (as in slow) c functions that take an > arrays and > parameters, process them and return one or more arrays to Ruby. > > These functions can take a long time to process and in some cases are > quite complex, so I really would like to keep them in c. > > Example: My program calculates the first 1000 elements of a function. > My c function can calculate all 1000 elements > in about the same time as it take to calculate the 999'th element, so > rather calling c over and over is way too slow! > > This function can have 1 to 6 parameters that are unknown until run > time > so I can't just "set them up" in advance. > I was thinking about making a hash so I could do something like > funcvals[(func_name + parm1.to_s + parm2.to_s > parm3.to_s).intern].storedvalue > but this is slow, ugly and messy! > > Does anyone have a clever/fast idea how to do this best in Ruby? > (I think this is the "opposite" of a lazy function. Is there a term > for this > so I can sound smarter next time?) > > Thanks, > Tom Tom, not quite sure whether I understood what you're after, but it might be Marshalling: http://www.ruby-doc.org/core/classes/Marshal.html Best regards, Axel -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx