C extension written for loop