From: Robert Klemme Date: 2011-04-27T22:06:11+09:00 Subject: Re: Fast way to move C array to ruby (rb_ary_new4)? On Wed, Apr 27, 2011 at 2:08 PM, Robert Klemme wrote: > On Wed, Apr 27, 2011 at 12:46 PM, Ville Sipola wrote: >> Would you know an efficient way of moving a large data from C array to >> ruby array? > > What about leaving it in C, i.e. wrapping in a specific type which > presents an Array (or Enumerable) like API and uses your C array > internally?  A similar approach is taken by ENV (you can find the code > in hash.c). PS: Of course whether that is more or less efficient than your approach totally depends on the usage pattern. If only few items in those arrays are accessed from Ruby land the wrapping approach is likely cheaper. If all items are accessed in the majority of cases then probably your original approach is better. I'd also look into NArray which might help you here. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/