P
progcat
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
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