IMO in borderline cases where it doesn't make much difference, we should
prefer to put *in* the 'const' annotation. It never hurts optimization and
sometimes, it makes code more self-documenting, and it can catch bugs
(where we accidentally try to modify something that we didn't mean to).
Const is awesome.


On Thu, May 23, 2013 at 4:29 PM, Charles Harris <notifications@github.com>wrote:

> In numpy/core/src/private/lowlevel_strided_loops.h:
>
> > @@ -396,6 +396,52 @@ typedef void (PyArray_StridedBinaryOp)(char *dst, npy_intp dst_stride,
> >                              char **out_dataB, npy_intp *out_stridesB,
> >                              char **out_dataC, npy_intp *out_stridesC);
> >
> > +
> > +/*
> > + * Return number of elements that must be peeled from
> > + * the start of 'addr' with 'nvals' elements of size 'esize'
> > + * in order to reach 'alignment'.
> > + * see npy_blocked_end for an example
> > + */
> > +static NPY_INLINE npy_intp
> > +npy_blocked_peel(const void * addr, const npy_intp esize,
>
> I expect that most of the const qualifiers can be omitted as the compiler
> can gather enough information about local variables to figure that out. The const
> void * is new to me ;)
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/numpy/numpy/pull/3341/files#r4363063>
> .
>