Hi. In integer.pyx I see a lot of code such as: cdef Integer z z = PY_NEW(Integer) # [...] mpz_somethingorother(z.value, somethingorother)
Is it necessary to explicitly use PY_NEW like this? I'd like to write code that "casts" a number to an Integer object. For example, in writing a function Integer.number_of_digits() I'd like to write cdef Integer size size = (Integer)(mpz_sizeinbase(self.value, base)) (One reason that I want to do it this way, other than simplicity, is that I don't necessarily know what type a size_t is.) Similarly, if x in an int and y and z are Integers, is it OK to write z = Integer(x)**y Anyway, this point isn't really why I want to write it this way. The question is really, is there any reason I shouldn't write it this way? Memory leaks? Efficiency? Maybe the real question is: In Cython code, when do I need to take care of memory management myself, and when can I count on the garbage collector? --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---