1

I have small question about garbage collection in Python.

Let's assume that i have class G

class G:
    someclassvariable = something
    def somemethod():
        nothing important here

I create instance of Class G that will be later collected by GC and modify someclassvariable. Is is safe to assume that the value of someclassvariable will remain modified? (In another words i am asking is GC doing anything with Class variables and if yes then what is he doing with them)

1 Answer 1

2

short answer: yes ;

the class variable remains modified, even when all instances are being unreferenced and garbage collected.

resources:

and you may find a lot of other documentation on the topic.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for your answer. I was testing it and it looked that way but wanted to be sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.