Internals.pod (PDL-2.077) | : | Internals.pod (PDL-2.078) | ||
---|---|---|---|---|
skipping to change at line 101 | skipping to change at line 101 | |||
pdl_trans_children trans_children; | pdl_trans_children trans_children; | |||
PDL_Indx def_dims[PDL_NDIMS]; /* Preallocated space for efficiency */ | PDL_Indx def_dims[PDL_NDIMS]; /* Preallocated space for efficiency */ | |||
PDL_Indx def_dimincs[PDL_NDIMS]; /* Preallocated space for efficie ncy */ | PDL_Indx def_dimincs[PDL_NDIMS]; /* Preallocated space for efficie ncy */ | |||
unsigned char def_broadcastids[PDL_NBROADCASTIDS]; | unsigned char def_broadcastids[PDL_NBROADCASTIDS]; | |||
struct pdl_magic *magic; | struct pdl_magic *magic; | |||
void *hdrsv; /* "header", settable from outside */ | void *hdrsv; /* "header", settable from outside */ | |||
PDL_Value value; /* to store at least one value */ | ||||
}; | }; | |||
This is quite a structure for just storing some data in - what is going on? | This is quite a structure for just storing some data in - what is going on? | |||
=head3 Data storage | =head3 Data storage | |||
We are going to start with some of the simpler members: first of all, | We are going to start with some of the simpler members: first of all, | |||
there is the member | there are the members (as of 2.078) | |||
void *datasv; | void *datasv; | |||
PDL_Value value; /* to store at least one value */ | ||||
which is really a pointer to a Perl SV structure (C<SV *>). The SV is | which are a pointer to a Perl SV structure (C<SV *>), and a union value | |||
of all possible single PDL values. If the ndarray's whole data | ||||
will fit in the C<value>, the C<datasv> will not be used except by | ||||
L<PDL::Core/get_dataref> for temporary use by Perl code. It will then | ||||
be destroyed by the call to L<PDL::Core/upd_data> method unless that | ||||
is passed a true value to keep the C<datasv> around (largely used by the | ||||
memory-mapping implementation). | ||||
Otherwise, the SV is | ||||
expected to be representing a string, in which the data of the ndarray | expected to be representing a string, in which the data of the ndarray | |||
is stored in a tightly packed form. This pointer counts as a reference | is stored in a tightly packed form. This pointer counts as a reference | |||
to the SV so the reference count has been incremented when the C<SV *> | to the SV so the reference count has been incremented when the C<SV *> | |||
was placed here (this reference count business has to do with Perl's | was placed here (this reference count business has to do with Perl's | |||
garbage collection mechanism -- don't worry if this doesn't mean much | garbage collection mechanism -- don't worry if this doesn't mean much | |||
to you). This pointer is allowed to have the value C<NULL> which | to you). This pointer is allowed to have the value C<NULL> which | |||
means that there is no actual Perl SV for this data - for instance, the data | means that there is no actual Perl SV for this data, as alluded above. | |||
might be allocated by a C<mmap> operation. Note the use of an SV* | Note the use of an SV* | |||
was purely for convenience, it allows easy transformation of | was purely for convenience, it allows easy transformation of | |||
packed data from files into ndarrays. Other implementations are not | packed data from files into ndarrays. Other implementations are not | |||
excluded. | excluded. | |||
The actual pointer to data is stored in the member | The actual pointer to data is stored in the member | |||
void *data; | void *data; | |||
which contains a pointer to a memory area with space for | which contains a pointer to a memory area with space for | |||
End of changes. 5 change blocks. | ||||
4 lines changed or deleted | 14 lines changed or added |