Logo

Programming-Idioms

History of Idiom 207 > diff from v4 to v5

Edit summary for version 5 by Oldboy:
New Python implementation by user [Oldboy]

Version 4

2019-10-02, 15:47:42

Version 5

2019-11-04, 18:59:53

Idiom #207 allocate a list that is automatically deallocated

Allocate a list / array a containing n elements (n assumed to be too large for a stack) that is automatically deallocated when the program exits the scope it is declared in.

Idiom #207 allocate a list that is automatically deallocated

Allocate a list / array a containing n elements (n assumed to be too large for a stack) that is automatically deallocated when the program exits the scope it is declared in.

Code
def func():
    a = [0] * n
    # local variable automatically deallocated at end of function
    return