Hello all > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:numpy- > [EMAIL PROTECTED] On Behalf Of Martin Wiechert > Sent: 15 September 2006 19:53 > To: Discussion of Numerical Python > Subject: Re: [Numpy-discussion]PyArray_DescrConverter - alignment / > trailingunused bytes > > On Friday 15 September 2006 19:14, Travis Oliphant wrote: > > Martin Wiechert wrote: > > > Thanks Albert! Do you also know the corresponding C-API function? It > > > cannot be PyArray_DescrConverter (PyObject *, PyArray_Descr **), whose > > > signature has no "align", right? > > > > The DescrConverter function is meant for "O&"-style conversions. It > > can't accept an align function. We could possibly add something to the > > converter to allow specification of alignment through the object to be > > converted. > >
> <snip> > One final question. To me the repr of a dtype with gaps is a little bit > puzzling: > > >>> dtype ({'names': ['a', 'b', 'c'], 'formats': ['<a4', '<f8', '<f4'], > 'offsets': [0, 16, 24]}) > dtype([('a', '|S4'), ('', '|V12'), ('b', '<f8'), ('', '|V12'), ('c', > '<f4')]) > > There should be no gap between "b" and "c" but still the repr has ('', > '|V12') > between them. Am I missing something? For performance reasons, compilers will typically align integers (and probably floats) on 4-byte boundaries and apparently, doubles on 16-byte boundaries. Because compilers align like this, so does NumPy. This allows you to: 1. Take any kind of C struct definition 2. Convert it to a dtype 3. Create a NumPy array with this dtype 4. Pass the array's data pointer to C code 5. Cast the data pointer to a pointer to your C struct 6. Operate on the pointer to struct as if it were allocated in C Cheers, Albert ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion