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
  • 138,652
  • 96
  • 297
  • 431

0 Answers0