On Sat, Aug 2, 2008 at 8:41 PM, Robert Bradshaw
<[EMAIL PROTECTED]> wrote:
> On Aug 2, 2008, at 10:40 AM, Ondrej Certik wrote:
>
>> Hi,
>>
>> $ cython -v
>> Cython version 0.9.8
>> $ cython --convert-range step.pyx
>> $ gcc -O3 -W -Wall -I/usr/include/python2.5/ -I/usr/include/numpy/ -c
>> -o step.o step.c
>> step.c: In function '__pyx_pf_4step_temperature':
>> step.c:608: warning: unused parameter '__pyx_self'
>> step.c: In function '__pyx_pf_4step_advance':
>> step.c:739: warning: unused parameter '__pyx_self'
>> step.c: In function '__pyx_pf_4step_assign_speeds':
>> step.c:1068: warning: unused parameter '__pyx_self'
>> step.c: In function '__pyx_pf_4step_fit_in_the_box':
>> step.c:1336: warning: unused parameter '__pyx_self'
>> step.c: In function '__pyx_pf_4step_get_f':
>> step.c:1675: warning: unused parameter '__pyx_self'
>> step.c: In function '__pyx_pf_4step_get_f2':
>> step.c:1794: warning: unused parameter '__pyx_self'
>> step.c: In function '__pyx_pf_4step_calculate_potential':
>> step.c:1941: warning: unused parameter '__pyx_self'
>> step.c: At top level:
>> step.c:2052: warning: missing initializer
>> step.c:2052: warning: (near initialization for
>> '__pyx_string_tab[11].is_identifier')
>> /usr/include/numpy/__multiarray_api.h:959: warning: '_import_array'
>> defined but not used
>>
>>
>>
>>
>> Now you can discover couple problems above. The last warning:
>>
>> step.c:2052: warning: missing initializer
>> step.c:2052: warning: (near initialization for
>> '__pyx_string_tab[11].is_identifier')
>>
>> could be fixed by this patch to the step.c file:
>>
>> $ quilt diff
>> Index: MD-spheres/step.c
>> ===================================================================
>> --- MD-spheres.orig/step.c 2008-08-02 19:36:34.680765668 +0200
>> +++ MD-spheres/step.c 2008-08-02 19:36:50.085854557 +0200
>> @@ -2049,7 +2049,7 @@
>> {&__pyx_kp_append, __pyx_k_append, sizeof(__pyx_k_append), 1, 1,
>> 1},
>> {&__pyx_kp_gauss, __pyx_k_gauss, sizeof(__pyx_k_gauss), 1, 1, 1},
>> {&__pyx_kp_get_f, __pyx_k_get_f, sizeof(__pyx_k_get_f), 0, 1, 1},
>> - {0, 0, 0, 0, 0}
>> + {0, 0, 0, 0, 0, 0}
>> };
>>
>> static struct PyMethodDef __pyx_methods[] = {
>>
>>
>>
>> So this seems like a bug in Cython. As to the other warnings:
>>
>> step.c:608: warning: unused parameter '__pyx_self'
>>
>> If you look into the generated file:
>>
>> static PyObject *__pyx_pf_4step_temperature(PyObject *__pyx_self,
>> PyObject *__pyx_args, PyObject *__pyx_kwds) {
>>
>>
>> Why does Cython generate the "self" argument? This is just a regular
>> function, not a method. And why isn't the first argument used? Is this
>> a bug?
>
> This is not a bug, it is because Python functions and methods have
> exactly the same signatures to be able to treat them interchangeably
> as first class objects. I believe in this case the self argument is
> the actual module, though it is clearly unneeded. If you look at the
> built in modules they do the exact same thing.
>
> Is there anything we could do to suppress this warning (fool the
> compiler into thinking it's used, but still have it be optimized away)?
I don't know, it'd be nice though surpress the warnings, since this is
a wanted behavior. So that gcc only warns when something goes wrong.
How about the other thing with 0,0,0 above? That seems to me like a bug.
Ondrej
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev