[Numpy-discussion] Toward a numpy build with warning: handling unused variable

David Cournapeau cournape@gmail....
Sun Aug 3 18:39:37 CDT 2008


On Mon, Aug 4, 2008 at 8:31 AM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
>
> But how many methods do arrays and types have? As many as 1500?

With autogenerated code, it is not difficult to imagine so many warnings.

>I think it
> is a bad idea to work around these sort of things. If self is needed, it
> belongs there. If not, it should be removed.

But that's the point: they can't be removed. The python C api force
you for any function to have two arguments:

static PyObject *
spam_system(PyObject *self, PyObject *args)

Many warnings are "warning: unused argument unused", or "warning:
dummy argument unused" :) You can't remove them form the argument
list.

> If the warnings are too
> numerous, filter them.

If you filter them, what's the point of keeping them ?

> And why would self go unused in any genuine method?

Because at the C level, both methods and functions have exactly the
signature, so for a function, you have an unused argument. AFAIK, most
C functions in numpy are functions, not methods. As I said, it is
inherent to the way C python functions are defined.

Again, using the mangling method would mean that any attempt to use
the argument would generate an error from the compiler, so you can't
hide anything.

cheers,

David


More information about the Numpy-discussion mailing list