On Feb 27, 2009, at 2:33 PM, Dan wrote:

> Testing and commenting out stuff revealed that the problem is
> accessing the arrays. No other code will make the Python interpreter
> crash.
>
> So either there's something wrong with my declaration or the way I  
> access it.
>
> On Fri, Feb 27, 2009 at 5:15 PM, Dan <[email protected]> wrote:
>>> Use "char", not "byte".
>>
>> Of course, you are right. However now it crashes the Python
>> interpreter when called.
>>
>> Current code:
>>
>> def fitness(int new_image, int original_image, int size):
>>
>>    cdef unsigned char *new_pixels = <unsigned char*><Py_ssize_t>size
>>    cdef unsigned char *original_pixels = <unsigned  
>> char*><Py_ssize_t>size

I am almost sure you don't want to be casting size to an unsigned  
char*...

>>
>>    cdef long spam = 0
>>    cdef int i = 0
>>    for i in range(size):
>>        spam += abs(original_pixels[i] - new_pixels[i])
>>
>>    return 255 * size - spam
>>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to