Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

python - Can a function reference avoid garbage collection?

Working with some funcional programming, I started wondering how does the garbage collector behaves with function/method references (for C# and Python's GC).

Let object A be an instance of a class with a method foo() and object B be an instance of a class with a field keeping a reference to object A's foo() method. Suposing that there is no other object referencing object A other than object B's method reference, will object A be collected by the garbage collector?

And how this scenario behaves with lambda functions?

question from:https://stackoverflow.com/questions/65929367/can-a-function-reference-avoid-garbage-collection

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...