Re:LPython: Novel, Fast, Retargetable Python Compiler
by akilkrishnan on Saturday July 29, 2023 @10:07PM
(#36927053)
What does this do with garbage collection? How does it choose between stack and heap allocations?
[ Parent
| on HN ]
Re:LPython: Novel, Fast, Retargetable Python Compiler
by certik on Sunday July 30, 2023 @10:38AM
(#36931579)
It doesn't do garbage collection. Variables and arrays get deallocated when they go out of scope (similar to C++ RAII). When you return from a function, it will be a copy, although I think we elide the copy in most cases. We restrict the Python subset in such a way that this exactly works with both LPython and CPython.
Local variables are on stack. Lists, dicts, sets and arrays use heap, unless the length is known at compile time, where we might use a stack, but I think we need to make it configurable, since one can run out of stack quite easily this way.