Hi all,

Just recently got into working with cython for speeding up some calculation
with numpy.

this question, however, has nothing to do with numpy.

The following code is valid python:

var = 0

def count(n):
    for i in range(n):
        var += i

    return var



Translating to cython results in run-time errors:

cdef double var = 0.0

def count(int n):
    cdef int i
    for i in range(n):
        var += i

    return var



However this works (as it should, it's the better way to do it):

def count(int n):
    cdef int i
    cdef double var = 0.0
    for i in range(n):
        var += i

    return var



now, i'm not debating that anyone would ever want to use the second method,
but regardless, in that version, why isn't var found in the module scope?

The runtime error i get is 'can't assign nonetype to int'



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

Reply via email to