Re: Python, the stack, and the heap

2018-12-18 Thread eryk sun
On 12/17/18, Chris Angelico wrote: > > Hang on, you're conflating two different things here. You're probably right that I misinterpreted what the OP meant by references winding up "on the stack". It's more common for a Python developer to think of the call stack instead of the implementation deta

Re: Python, the stack, and the heap

2018-12-17 Thread Chris Angelico
On Tue, Dec 18, 2018 at 9:12 AM eryk sun wrote: > Objects are heap allocated and use reference counting in CPython (i.e. > Python implemented in C). A scope reference in CPython could be a fast > (function) local that's internal to a frame object; a cell object > that's used to share variables in

Re: Python, the stack, and the heap

2018-12-17 Thread eryk sun
On 12/17/18, Rob Gaddi wrote: > > Python's objects all have a lifespan dictated by the continued existence > of references to them and thus can transcend the lifetime of the current > function in ways not known at translation time. So am I right in > thinking that all Python objects are out on th

Re: Python, the stack, and the heap

2018-12-17 Thread Chris Angelico
On Tue, Dec 18, 2018 at 6:36 AM Rob Gaddi wrote: > > I've been writing Python for good long while now without thinking too > hard about this, but I just had a realization this weekend. > > Back when the earth's crust was still cooling and we all rode dinosaurs > to our jobs, local variables got al