[Numpy-discussion] Changeset 6557

Charles R Harris charlesr.harris@gmail....
Sat Mar 7 12:20:56 CST 2009


On Sat, Mar 7, 2009 at 11:02 AM, David Cournapeau <cournape@gmail.com>wrote:

> On Sun, Mar 8, 2009 at 2:52 AM, Charles R Harris
> <charlesr.harris@gmail.com> wrote:
> >
> >
> > On Sat, Mar 7, 2009 at 11:41 AM, David Cournapeau <cournape@gmail.com>
> > wrote:
> >>
> >> On Sat, Mar 7, 2009 at 6:01 AM, Charles R Harris
> >> <charlesr.harris@gmail.com> wrote:
> >> > Hi David,
> >> >
> >> > Currently,
> >> >
> >> > bint.i = __STR2INTCST("ABCD");
> >> >
> >> > It is probably more portable to just initialize the union
> >> >
> >> >     union {
> >> >         char c[4];
> >> >         npy_uint32 i;
> >> >     } bint = {'A','B','C','D'};
> >> >
> >
> > Yes, but look at the second version. It does essentially what your macro
> > does, only uses 1,2,3,4 instead of 'A','B','C','D'.
>
> Yes, it is the same thing, so I don't see the point of changing :)


The macro is ugly, unneeded, and obfuscating. Why construct a number from
characters and shifts when you can just *write it down*?


> The
> const union does not help, BTW.


True, it is initialized here:

        movl    $16909060, -8(%ebp)

contrast that with the macro.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090307/118f902c/attachment.html 


More information about the Numpy-discussion mailing list