• Damien George's avatar
    py/nlr: Implement jump callbacks. · 2757acf6
    Damien George authored
    
    
    NLR buffers are usually quite large (use lots of C stack) and expensive to
    push and pop.  Some of the time they are only needed to perform clean up if
    an exception happens, and then they re-raise the exception.
    
    This commit allows optimizing that scenario by introducing a linked-list of
    NLR callbacks that are called automatically when an exception is raised.
    They are essentially a light-weight NLR handler that can implement a
    "finally" block, i.e. clean-up when an exception is raised, or (by passing
    `true` to nlr_pop_jump_callback) when execution leaves the scope.
    Signed-off-by: default avatarDamien George <damien@micropython.org>
    2757acf6
nlr.h 7.25 KB