From: james.d.masters@... Date: 2007-06-22T03:00:03+09:00 Subject: Re: Ruby extensions question.. On Jun 21, 10:22 am, Aaron Smith wrote: > So I'm getting slightly confused with writing ruby extensions and what > is best for performance. > > I'm working on writing an extension for Ruby, but almost everything i'm > doing at the C level is with rb_* functions using the Ruby C API. I > understand how it works but isn't that just as slow as using Ruby? Or > no? > > thanks > > -- > Posted viahttp://www.ruby-forum.com/. The performance improvement is not found in the Ruby interface to C but rather in what is going on in the C code itself. Example: I write C code that does something computationally intensive - say it takes about 1 hour to run. If I were to write a Ruby equivalent (only in Ruby) then let's say that it takes 2 hours. But if I extend that C code using the Ruby C API then my performance would be 1 hour plus interface (rb_*) overhead - maybe on the order of a few seconds or perhaps minutes.