in reply to embed perl: Can I avoid to copy a c array?

As pointed out, the answer is no.

The reason the answer is no is that in Perl values are much more complex than in C. In C, doubles take 4 or 8 bytes, depending on the platform, and they just have the numerical information. In C, the array is nothing more than all the doubles put sequentially in memory. In Perl, a double will be stored in a C struct, with one its field containing the numerical value. The array will contain pointers to SVs, which themselves are C structs as well, one of its fields a pointer to the struct containing the numerical value. So, in C, an array element can be referenced with just a single offset from the C pointer to the array; in Perl it takes an extra two pointer dereferences (and offsets).

  • Comment on Re: embed perl: Can I avoid to copy a c array?