3 ms·
No definitive answer, but educated guess: I'm not sure how things are in Ruby, but in Python frame object lifetime does not correspond to the C stack implementi
by dmw_ng 5y ago
No definitive answer, but educated guess: I'm not sure how things are in Ruby, but in Python frame object lifetime does not correspond to the C stack implementing the interpreter. If your code throws an exception, frames are returned as part of the public API of the exception object, and can thus indefinitely outlive the associated function execution.
You could still implement an array-oriented frame stack in Python, but I think that would mean exceptions become more expensive, as it means making a complete copy of the array any time an exception was thrown, even if the user never makes use of it.
- the_mitsuhiko 5y agoIt would be trivial to change from a linked list to an allocated vector if it were not for exposed APIs. In fact it would most likely be more efficient.
- gpderetta 5y agoInteresting. Wasn't the selling point of Stackless Python that it did not use the C stack (as done by CPython) as the Python stack?