Should I worry about circular references in Python?

前端 未结 6 560

Suppose I have code that maintains a parent/children structure. In such a structure I get circular references, where a child points to a parent and a parent points to a chil

6条回答
  •  被撕碎了的回忆
    2020-12-02 18:55

    Experimentally: you're fine:

    import itertools
    
    for i in itertools.count():
        a = {}
        b = {"a":a}
        a["b"] = b
    

    It consistently stays at using 3.6 MB of RAM.

提交回复
热议问题