On Apr 14, 2009, at 9:17 AM, Dag Sverre Seljebotn wrote: > I was just thinking about this: > > cdef int a = 10, b = 0 > print a // b > > which currently gives a C exception terminating the Python > interpreter. > > On one hand: We have already changed division to Python behaviour > (with > a speed penalty); so using the same arguments (which I won't > reiterate) > it would make sense to raise a Python exception instead here. > > It seems to make sense to couple this as well to the cdivision > directive > and cython.cdiv function. > > On the other hand: Well, all the arguments that was against > changing // > to Python behaviour.
Since we changed it, we should chang it all the way. It will be somewhat uglier as this means when writing a / (c-c) one needs to store the denominator in a temp and check it rather than simply letting the expression through to C (I already did this for warnings). > But in addition: > > This is coupled with the "exception under nogil" issue that I > raised in > another thread today, as one should definitely be allowed to do C > division within a nogil section. > > One solution would be to work on accepting exceptions under nogil, > another one would be to require use of cdivision directive/cdiv to do > division in nogil sections. I don't think exceptions are safe without the gil. With cdivision on it won't raise anything. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
