Does CPython's garbage collection do compaction?

后端 未结 1 802
一个人的身影
一个人的身影 2021-01-13 11:50

I was talking with a friend, comparing languages, and he mentioned that Java\'s automated memory management is superior to Python\'s as Java\'s does compaction, while Python

相关标签:
1条回答
  • 2021-01-13 12:25

    I don't know for sure, but CPython uses reference counting and its objects use memory addresses as ids so I would say it does not do compaction... And according to this, "[C]Python does not use memory compaction ... [w]ould Python use memory compaction, implementing C extensions would be much more tedious and error prone and there would be less such extensions - limiting the domain where Python is used."

    0 讨论(0)
提交回复
热议问题