Python functions often create temporary variables for intermediate computations, which can clutter the local namespace and potentially lead to memory leaks if not properly managed. mswp addresses this issue by providing a simple yet powerful decorator that automatically cleans up temporary local variables, ensuring an efficient execution environment.
You can install mswp via pip:
pip3 install mswp
To use mswp, simply decorate your functions with @mswp. This ensures that any temporary local variables used within the function are cleared upon completion, promoting code cleanliness and efficient memory usage.
from mswp import clear
@clear
def my_function():
temp_var = 10
# Your code here
return result
Features
- Automatic Cleanup: mswp automatically clears temporary local variables after function execution, preventing clutter and potential memory leaks.
- Simplified Syntax: With a simple decorator, mswp streamlines code maintenance and promotes readability.
- Error Handling: mswp provides robust error handling to ensure reliable execution even in the presence of exceptions.
1 comment
[ 2.2 ms ] story [ 9.8 ms ] threadYou can install mswp via pip: pip3 install mswp
To use mswp, simply decorate your functions with @mswp. This ensures that any temporary local variables used within the function are cleared upon completion, promoting code cleanliness and efficient memory usage.
from mswp import clear
@clear def my_function(): temp_var = 10 # Your code here return result
Features - Automatic Cleanup: mswp automatically clears temporary local variables after function execution, preventing clutter and potential memory leaks. - Simplified Syntax: With a simple decorator, mswp streamlines code maintenance and promotes readability. - Error Handling: mswp provides robust error handling to ensure reliable execution even in the presence of exceptions.