Re: [sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-20 Thread Vincent Delecroix
It might be allowed but I do not see the point of using it. The most reasonable way is cdef int a # or possibly, unsigned int, size_t, etc for a in range(100): ... And this has to be thought as the C for loop int a; for(a = 0; a < 100; a++) ... And as Volker said, it is always a good idea

Re: [sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-20 Thread Frédéric Chapoton
xrange will stilll be allowed in cython files, even after (if) we switch to python3 Frederic Le jeudi 20 octobre 2016 11:47:38 UTC+2, Johan S. R. Nielsen a écrit : > > >> sage: a = range(10**8) # takes a lot of memory > >> sage: del a# free the memory > > > > Ok, so now,

Re: [sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-20 Thread Johan S . H . Rosenkilde
>> sage: a = range(10**8) # takes a lot of memory >> sage: del a# free the memory > > Ok, so now, I understand why it takes the memory: a list was created. Using xrange instead of range will also avoid creating the list even without cdef'ing a (the code is still slow of cour

Re: [sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-20 Thread Sébastien Labbé
On Thursday, October 20, 2016 at 8:42:05 AM UTC+2, vdelecroix wrote: > It might not be a leak. *After* the loop the memory should be back to > normal. The very same as with > > sage: a = range(10**8) # takes a lot of memory > sage: del a# free the memory Ok, so now, I und

[sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-19 Thread Volker Braun
On Thursday, October 20, 2016 at 1:19:51 AM UTC+2, Sébastien Labbé wrote: > > Does this also explain the leak? > Freed memory is not immediately returned to the system (mostly because it would be hilariously slow for small allocations). Whether a one-off computation increases process memory usag

Re: [sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-19 Thread Vincent Delecroix
It might not be a leak. *After* the loop the memory should be back to normal. The very same as with sage: a = range(10**8) # takes a lot of memory sage: del a# free the memory Vincent PS: This would have been different with Python 3. -- You received this message because yo

[sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-19 Thread Sébastien Labbé
Does this also explain the leak? -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage

[sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-19 Thread Volker Braun
PS: Write your code in a file and compile it with "cython -a myfile.pyx", that generates a html file with explanations. On Thursday, October 20, 2016 at 1:11:14 AM UTC+2, Volker Braun wrote: > > Thats the expected behavoir. Without type annotation, cython just does the > same as Python (creat

[sage-devel] Re: cython memory leak when one's forget to cdef the for loop variable

2016-10-19 Thread Volker Braun
Thats the expected behavoir. Without type annotation, cython just does the same as Python (create a list of 10**8 elements and iterate over). With type annotation it is a C-level for loop. On Thursday, October 20, 2016 at 12:33:47 AM UTC+2, Sébastien Labbé wrote: > > Dear sage-devel, > > Writin