user2184057
user2184057

Reputation: 964

Python Garbage-Collector and Class Variables

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)

Upvotes: 1

Views: 749

Answers (1)

zmo
zmo

Reputation: 24812

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.

Upvotes: 2

Related Questions