Hi, Thanks for the pointer. I have checked the Flyweight pattern, but probably it is not what I need as in my case each entity has totally different data. I have done further tests. Using straight Ruby, my code efficiency is 32,000 events/second. Transforming the core into C increases it to 160,000 events/second. Using manually written doubly-linked list instead of Ruby array increases it further to 198,000 events/second. I have read in the pick-axe book that Ruby (or any scripting language in general) is not suitable for heavy processing code. However, I have also experienced all the trouble writing code in C (with its segmentation faults and memory leaks). So I am trying to get the best of both worlds, by making a system that is flexible. In other words, for people who want to develop quickly, they can write it in Ruby; for people who are more adventurous, they can write it in C. And of course, the highest level script input can work with either. Only when I try to convert the core into C, I realize how much constraint Ruby puts on my flexibility in writing C. I guess this is the penalty that has to be paid for the compatibility in the script input. It seems Matz suggested creating "lazy evaluating" Ruby objects, but to me it appears that Ruby object creation still takes too much execution overhead. Probably there is indeed no solution to this problem. Regards, Bill ========================================================================= Curt Sampson <cjs / cynic.net> wrote: > You might consider reusing objects, rather than creating and destroying > them every time. There are also design patterns, such as Flyweight, that > you might be able to apply to help with this. > cjs