On Wed, Feb 29, 2012 at 10:02 AM, William Stein <wst...@gmail.com> wrote:
> On Wed, Feb 29, 2012 at 9:55 AM, Volker Braun <vbraun.n...@gmail.com> wrote:
>> Python uses a garbage collector to reclaim memory. Objects don't die just
>> because they fall out of scope, they will be around until the next GC cycle.
>
> Minor note:  At least when using Cython, sometimes objects will be
> freed when they fall out of scope if they are not part of a circular
> reference cycle.   It is useful to look at
>
>   python-2.7.2.p1/src/Include/object.h
>
> to see what Py_DECREF actually does.

In general (not just Cython) a Python object is deallocated as soon as
it's no longer referenced (via the Py_DECREF macro), which is often as
soon as they fall out of scope. The garbage collector is used to
reclaim cyclically-referenced objects. Note also that ipython (used at
the Sage prompt) also keeps a lot of references to old results around,
making it difficult to do such analysis at the command line.

- Robert

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to