[Numpy-discussion] record descriptors: trailing unused bytes

Martin Wiechert Martin.Wiechert at mpimf-heidelberg.mpg.de
Mon Sep 18 17:12:31 CDT 2006


On Monday 18 September 2006 20:46, Travis Oliphant wrote:
> Martin Wiechert wrote:
> > Hi list,
> >
> > does anybody know, if in C in the PyArray_Descr struct it is safe to
> > manually change descr->elsize and descr->alignment as long as these are
> > compatible and descr->elsize is large enough to hold all fields? Of
> > course I mean before any array is constructed using descr.
>
> Well, you should really make a copy of the PyArray_Descr structure and
> then fill it in as desired unless you are sure that no other arrays have
> are using that particular data-type object to describe their own data:
> PyArray_DescrNew gives you a new copy based on an old one (you just get
> a reference to the funciton pointers in the 'f' member so don't go
> changing those).
>
> I guess your statement about "before any array is constructed using
> descr" means you are sure that there are no other arrays using the old
> elsize and alignment.
>
> Then it should be fine.  There are not supposed to be any assumptions
> about the data-types except for what is explicitly provided in the
> data-type object (PyArray_Descr *).  So, changing them will change the
> data-type and things should ideally work.
>
> -Travis
>

Thanks

>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your opinions on IT & business topics through brief surveys -- and earn
> cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-------------- next part --------------
AV scanned by FortiGate


More information about the Numpy-discussion mailing list