Inside the Python VM: Cells and Closures
摘要
In the previous chapter, we discussed the LEGB scope design and encountered a special object called the Cell Object. In Python, this object is used to implement the concept of “closure.” Many programming languages feature closures, and in this chapter, we will explore what a Cell Object is and how closures are designed by looking directly at the CPython source code.