Question about lua gc vs python gc

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about lua gc vs python gc

吴曼硕
Hi, when i reading python doc, i find that if python objects have __del__() methods, and they would not be collected by gc. Because python do not know the save order to run __del__() methods.But, i notice that lua do not have such worries about the order of calling __gc(). So what's difference between lua and py while running fini methods(python's __del__() vs lua's __gc()).

python doc:https://docs.python.org/2.7/library/gc.html#gc.garbage

Thanks!!!
Thorwu
Reply | Threaded
Open this post in threaded view
|

Re: Question about lua gc vs python gc

Victor Bombi

for 5.1 for example https://www.lua.org/manual/5.1/manual.html#2.10

On July 28, 2020 at 10:19 AM 吴曼硕 <[hidden email]> wrote:

Hi, when i reading python doc, i find that if python objects have __del__() methods, and they would not be collected by gc. Because python do not know the save order to run __del__() methods.But, i notice that lua do not have such worries about the order of calling __gc(). So what's difference between lua and py while running fini methods(python's __del__() vs lua's __gc()).

python doc: https://docs.python.org/2.7/library/gc.html#gc.garbage

Thanks!!!
Thorwu
Reply | Threaded
Open this post in threaded view
|

Re: Question about lua gc vs python gc

Robert Burke
On Tue, Jul 28, 2020 at 6:28 PM Victor Bombi <[hidden email]> wrote:
>
> for 5.1 for example https://www.lua.org/manual/5.1/manual.html#2.10
>

I think the 5.4 manual explains the approach a bit better:
https://www.lua.org/manual/5.4/manual.html#2.5.3. I don't know the
details of Python's GC, but it seems like the technique would not be
much trouble to use in a different runtime.