[PATCH rfc] rfc: call gc at exit of mercurial

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Apr 5 02:36:26 EDT 2016



On 04/04/2016 10:31 PM, Maciej Fijalkowski wrote:
> class A(object):
>      def __del__(self):
>          print "del"
>
> class B(object):
>      pass
>
> b = B()
> b.b = b
> b.a = A()
>
>
> This example does not call __del__ in CPython either.
>
> The __del__ is not guaranteed to be called - that's why there is a
> painful module finalization procedure where CPython is trying to call
> "as much as possible", but there are still no guarantees. If you add
> del b; gc.collect() you will see "del" printed. Of course this
> involves a cycle, but cycles can come in ways that you don't expect
> them and PyPy simply says "everything is GCed". I think it's very much
> in line with what python-dev thinks.

Which is why we have __del__ in very few object and we deploy massive 
effort to ensure their don't get caught in cycle and mostly succeeding 
at this. (Kind of the same we put a lot of effort into making sure 
__del__ are never really called but keep them as double safety).

So in the case we care about (no cycle) Cpython would call our __del__, 
right?

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list