Why 3 references with python literals?
>>> 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?
No comments:
Post a Comment