From: Aaron Smith Date: 2007-06-22T05:28:17+09:00 Subject: Re: Ruby extensions question.. MenTaLguY wrote: > On Fri, 22 Jun 2007 03:55:11 +0900, Aaron Smith > wrote: >> One more question. Maybe this will end up having the same answer.. But >> let's say I have an object that I pass to the ruby extension. and all >> operations in the C code i'm doing are on that object passed using >> rb_funcall, rb_iv_get, etc. is it still seeing performance gains with C? > > Usually not much. Local variables are a little cheaper, and there's no > AST-walking for evaluation, but that's about the extent of it. Ruby > method calls are a lot more expensive, so the big wins are when you can > avoid Ruby method calls (i.e. rb_funcall) altogether. Otherwise, it's > just not worth the maintainability and portability problems. > > -mental Thanks, helps more. I think where I'm going with this is that its best to write a C program that does everything needed. Then come back and extend Ruby with those pieces. Instead of worrying about Ruby integration now, wait till the straight C functionality is there.. Then there should only be slight overhead of a few rb_* calls. -- Posted via http://www.ruby-forum.com/.