From: Ville Sipola Date: 2011-04-27T19:46:33+09:00 Subject: Fast way to move C array to ruby (rb_ary_new4)? Good day I have a number of large arrays in a C module, and I'd need to move them to ruby as quickly as possible. Currently I use the following type of an approach: instance_array_in_ruby = rb_iv_get(calling_class, "@x"); double c_array[1000000]; for(i=0;i<1000000;i++) { rb_ary_store(instance_array_in_ruby, i, rb_float_new(c_array[i])); } But that's slow, apparently due to the large number of rb_float_new:s. There is a function called rb_ary_new4 that would seem to fit the purpose of quickly moving an entire C array to ruby. Only I'm unable to get it work, as it, too requires VALUE:s. I've tried many things including mumbo-jumbo like rb_iv_set(calling_class,"@x",rb_ary_new4(1000000, (VALUE)c_array));, but I'm only managing to get segfaults or solutions that still need a million rb_something_new:s. Would you know an efficient way of moving a large data from C array to ruby array? -- Posted via http://www.ruby-forum.com/.