memorymanagement 1.1.1__tar.gz → 1.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/PKG-INFO +1 -1
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement/cleaning/core.py +7 -8
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement/pointers/core.py +1 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement.egg-info/PKG-INFO +1 -1
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/setup.cfg +1 -1
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/LICENSE +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/README.md +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement/__init__.py +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement/cleaning/__init__.py +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement/pointers/__init__.py +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement/pointers/decorators.py +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement.egg-info/SOURCES.txt +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement.egg-info/dependency_links.txt +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement.egg-info/top_level.txt +0 -0
- {memorymanagement-1.1.1 → memorymanagement-1.1.3}/pyproject.toml +0 -0
|
@@ -42,7 +42,7 @@ class Cleaner:
|
|
|
42
42
|
Returns the list of variables to be erased from memory.
|
|
43
43
|
None of this properties has setter or deleter. Those lists can only be manipulated through the class methods.
|
|
44
44
|
"""
|
|
45
|
-
def __init__(self,not_delete:list[str]=
|
|
45
|
+
def __init__(self,not_delete:list[str]|None=None,excluded:list[str]=[],flagged:list[str]=[]):
|
|
46
46
|
"""
|
|
47
47
|
Initializes the class instance.\n
|
|
48
48
|
It is recommended to initialize the instance right after all global imports at the beggining of the program so no argument is needed.
|
|
@@ -53,13 +53,14 @@ class Cleaner:
|
|
|
53
53
|
excluded (`list[str]`, Optional): List of variables to be excluded from the memory cleaning process. Empty list by default.
|
|
54
54
|
flagged (`list[str]`, Optional): List of variables to be erased from memory. Empty list by default.
|
|
55
55
|
"""
|
|
56
|
+
if not not_delete:
|
|
57
|
+
not_delete=list(vars(modules["__main__"]))
|
|
56
58
|
for key,value in vars(modules["__main__"]).copy().items():
|
|
57
59
|
if isinstance(value,Cleaner) and key in vars(modules["__main__"]).keys():
|
|
58
60
|
del vars(modules["__main__"])[key]
|
|
59
61
|
self._not_delete=not_delete.copy()
|
|
60
62
|
self._excluded=excluded.copy()
|
|
61
63
|
self._flagged=flagged.copy()
|
|
62
|
-
return
|
|
63
64
|
def update(self,exclude:str|list[str]|tuple[str]|None=None,include:str|list[str]|tuple[str]|None=None):
|
|
64
65
|
"""
|
|
65
66
|
Flags all the new global variables' references that were not manually excluded here or before. You can also include previously excluded references.
|
|
@@ -81,10 +82,11 @@ class Cleaner:
|
|
|
81
82
|
for var in include:
|
|
82
83
|
while var in self._excluded:
|
|
83
84
|
self._excluded.remove(var)
|
|
84
|
-
self._flagged=[var for var in list(vars(modules["__main__"]))
|
|
85
|
-
return
|
|
85
|
+
self._flagged=[var for var in list(vars(modules["__main__"]))if var not in self.not_delete and var not in self.excluded]
|
|
86
86
|
@property
|
|
87
87
|
def not_delete(self):
|
|
88
|
+
if list(vars(modules["__main__"]))[list(vars(modules["__main__"]).values()).index(self)] not in self._not_delete:
|
|
89
|
+
self._not_delete.append(list(vars(modules["__main__"]))[list(vars(modules["__main__"]).values()).index(self)])
|
|
88
90
|
return self._not_delete
|
|
89
91
|
@property
|
|
90
92
|
def excluded(self):
|
|
@@ -105,7 +107,6 @@ class Cleaner:
|
|
|
105
107
|
self._flagged.remove(var)
|
|
106
108
|
if var not in self._excluded:
|
|
107
109
|
self._excluded.append(var)
|
|
108
|
-
return
|
|
109
110
|
def include(self,*include:str):
|
|
110
111
|
"""
|
|
111
112
|
Allows to include the desired references (previously excluded) in the cleaning process.
|
|
@@ -119,7 +120,6 @@ class Cleaner:
|
|
|
119
120
|
self._flagged.append(var)
|
|
120
121
|
while var in self._excluded:
|
|
121
122
|
self._excluded.remove(var)
|
|
122
|
-
return
|
|
123
123
|
def clean(self):
|
|
124
124
|
"""
|
|
125
125
|
Culminates the cleaning process. Erases all the flagged references.
|
|
@@ -128,7 +128,6 @@ class Cleaner:
|
|
|
128
128
|
if var in list(vars(modules["__main__"])):
|
|
129
129
|
del vars(modules["__main__"])[var]
|
|
130
130
|
self._flagged.clear()
|
|
131
|
-
return
|
|
132
131
|
def __str__(self):
|
|
133
132
|
string=f"""
|
|
134
133
|
Flagged: {self.flagged}
|
|
@@ -139,4 +138,4 @@ class Cleaner:
|
|
|
139
138
|
"""
|
|
140
139
|
return string
|
|
141
140
|
def __repr__(self):
|
|
142
|
-
return f"{self.__class__.__name__}(flagged={self.flagged})"
|
|
141
|
+
return f"{self.__class__.__name__}(not_delete={self.not_delete},excluded={self.excluded},flagged={self.flagged})"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#*===============================================================================================================================
|
|
2
2
|
#* LEGEND
|
|
3
|
+
#*-------------------------------------------------------------------------------------------------------------------------------
|
|
3
4
|
#! Missing
|
|
4
5
|
#? Question
|
|
5
6
|
#* Section
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{memorymanagement-1.1.1 → memorymanagement-1.1.3}/memorymanagement.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|