5
>>> class Foo(object): pass
... 
>>> sys.getrefcount(Foo())
1
>>> sys.getrefcount(12323451234.121213)
3
>>> sys.getrefcount(12323451234)
3
>>> sys.getrefcount("Hello")
3

I am amused by this situation. Apparently literals (even those who are brought into existence on the spot) have a refcount of three. Why is that?

Stefano Borini
  • 132,232
  • 95
  • 283
  • 413

0 Answers0