memorymanagement 1.0.0__py3-none-any.whl → 1.1.0__py3-none-any.whl
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/cleaning/__init__.py +40 -1
- memorymanagement/cleaning/{cleaning.py → core.py} +12 -1
- memorymanagement/pointers/__init__.py +12 -0
- memorymanagement/pointers/core.py +13 -1
- {memorymanagement-1.0.0.dist-info → memorymanagement-1.1.0.dist-info}/METADATA +16 -10
- memorymanagement-1.1.0.dist-info/RECORD +11 -0
- {memorymanagement-1.0.0.dist-info → memorymanagement-1.1.0.dist-info}/licenses/LICENSE +21 -21
- memorymanagement-1.0.0.dist-info/RECORD +0 -11
- {memorymanagement-1.0.0.dist-info → memorymanagement-1.1.0.dist-info}/WHEEL +0 -0
- {memorymanagement-1.0.0.dist-info → memorymanagement-1.1.0.dist-info}/top_level.txt +0 -0
|
@@ -1,2 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# Module `cleaning`
|
|
3
|
+
Implements the class `Cleaner` to keep track of the references and erase it easily.
|
|
4
|
+
## Overview
|
|
5
|
+
Initialize a `Cleaner` object:
|
|
6
|
+
```
|
|
7
|
+
# Default arguments' values
|
|
8
|
+
cleaner=Cleaner(
|
|
9
|
+
not_delete:list[str]=list(vars(modules["main"])), # List of global variables at that moment (modules comes from sys library)
|
|
10
|
+
excluded:list[str]=[], # Empty list to be modified later if you need
|
|
11
|
+
flagged:list[str]=[] # List of references to undo
|
|
12
|
+
)
|
|
13
|
+
```
|
|
14
|
+
Now `cleaner` has the following attributes:
|
|
15
|
+
```
|
|
16
|
+
cleaner._not_delete=list(vars(modules["main"])) # At initialization moment
|
|
17
|
+
cleaner._excluded=[] # Wasn't asked to exclude any reference.
|
|
18
|
+
cleaner._flagged=[] # Wasn't asked to include any reference.
|
|
19
|
+
```
|
|
20
|
+
To automatically include all the new references, use the `.update()` method:
|
|
21
|
+
```
|
|
22
|
+
x=10
|
|
23
|
+
y="Hello world"
|
|
24
|
+
z=f"Hello Python for time number {x}"
|
|
25
|
+
# Default arguments' values
|
|
26
|
+
cleaner.update(
|
|
27
|
+
exclude:str|list[str]|tuple[str]|None=None, # Excludes flagged or yet not created references from the process
|
|
28
|
+
include:str|list[str]|tuple[str]|None=None # Includes references into the process
|
|
29
|
+
)
|
|
30
|
+
print(cleaner)
|
|
31
|
+
```
|
|
32
|
+
The cell above prints (via `__str__` method):
|
|
33
|
+
```
|
|
34
|
+
Flagged: ["x","y","z"]
|
|
35
|
+
|
|
36
|
+
Excluded: []
|
|
37
|
+
|
|
38
|
+
Not delete: <list(vars(modules["main"]))> # Unchanged since initialization
|
|
39
|
+
"""
|
|
1
40
|
# Imports
|
|
2
|
-
from .
|
|
41
|
+
from .core import Cleaner
|
|
@@ -128,4 +128,15 @@ 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
|
|
131
|
+
return
|
|
132
|
+
def __str__(self):
|
|
133
|
+
string=f"""
|
|
134
|
+
Flagged: {self.flagged}
|
|
135
|
+
|
|
136
|
+
Excluded: {self.excluded}
|
|
137
|
+
|
|
138
|
+
Not delete: {self.not_delete}
|
|
139
|
+
"""
|
|
140
|
+
return string
|
|
141
|
+
def __repr__(self):
|
|
142
|
+
return f"{self.__class__.__name__}(flagged={self.flagged})"
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# Module `pointers`
|
|
3
|
+
A safe implementation of pointers written in pure Python.
|
|
4
|
+
|
|
5
|
+
It is safe beacause it doesn't imitate the internal behaviour of C pointers because it could break the memory.
|
|
6
|
+
It only replicates the visible effects and behaviour of C pointers.
|
|
7
|
+
## Class `Pointer`
|
|
8
|
+
This is the core of the module. The class `Pointer` points to a specific reference,
|
|
9
|
+
which will be syncrhonized with the pointer's value since the moment of the pointer's creation.
|
|
10
|
+
## Decorator `pointerize`
|
|
11
|
+
This decorator makes any function able to receive `Pointer` objects instead of the originally expected.
|
|
12
|
+
"""
|
|
1
13
|
# Import from modules
|
|
2
14
|
from .core import Pointer # Class "Pointer"
|
|
3
15
|
from .decorators import pointerize # Decorator "pointerize"
|
|
@@ -124,4 +124,16 @@ class Pointer(Generic[object_type]):
|
|
|
124
124
|
del self._value
|
|
125
125
|
if self._name:
|
|
126
126
|
del self._vars_dict[self._name]
|
|
127
|
-
return
|
|
127
|
+
return
|
|
128
|
+
def __getitem__(self,index):
|
|
129
|
+
return self.value[index]
|
|
130
|
+
def __setitem__(self,index,value):
|
|
131
|
+
self.value[index]=value
|
|
132
|
+
return
|
|
133
|
+
def __delitem__(self,index):
|
|
134
|
+
del self.value[index]
|
|
135
|
+
return
|
|
136
|
+
def __str__(self):
|
|
137
|
+
return str(self.value)
|
|
138
|
+
def __repr__(self):
|
|
139
|
+
return f"{self.__class__.__name__}({self.value})"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memorymanagement
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Adds support for memory management
|
|
5
|
-
Home-page: https://github.com/Ricardo-Werner-Rivas/python-memory-management/tree/
|
|
5
|
+
Home-page: https://github.com/Ricardo-Werner-Rivas/python-memory-management/tree/PyPI
|
|
6
6
|
Author: Ricardo Werner Rivas
|
|
7
7
|
Author-email: ricardowernerrivas@gmail.com
|
|
8
8
|
License: MIT
|
|
9
|
-
Project-URL:
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/Ricardo-Werner-Rivas/python-memory-management/issues
|
|
10
10
|
Project-URL: Repository, https://github.com/Ricardo-Werner-Rivas/python-memory-management
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
12
|
Classifier: Operating System :: Microsoft :: Windows
|
|
@@ -16,6 +16,9 @@ Dynamic: license-file
|
|
|
16
16
|
|
|
17
17
|
# `memorymanagement`
|
|
18
18
|
Provides memory management support.
|
|
19
|
+
|
|
20
|
+
The only Python implementation currently supported is the one made by the **CPython** team.
|
|
21
|
+
The rest remain untested.
|
|
19
22
|
## Modules
|
|
20
23
|
### `cleaning`
|
|
21
24
|
Provides the class `Cleaner`, which allows you to flag references stored in memory to eventually erase them.
|
|
@@ -27,15 +30,10 @@ The pointer itself. Imitates the behaviour of C pointers. This pointer points to
|
|
|
27
30
|
#### Decorator `pointerize`
|
|
28
31
|
Allows functions to receive pointers instead of values.
|
|
29
32
|
## Installation
|
|
30
|
-
You can install the `
|
|
31
|
-
```
|
|
33
|
+
You can install the `memorymanagement` package from PyPI as follows:
|
|
34
|
+
```ps
|
|
32
35
|
pip install memorymanagement
|
|
33
36
|
```
|
|
34
|
-
You can also install the `memorymanager` package (Test PyPI versión of `memorymanager`) from TestPyPI as follows:
|
|
35
|
-
```bash
|
|
36
|
-
pip install --index-url https://test.pypi.org/simple/ memorymanager
|
|
37
|
-
```
|
|
38
|
-
For TestPyPI versión, `--no-deps` option is not needed because it has no dependencies.
|
|
39
37
|
## How to use
|
|
40
38
|
### Class `Cleaner`
|
|
41
39
|
```py
|
|
@@ -160,3 +158,11 @@ Value: 10
|
|
|
160
158
|
Value: 20
|
|
161
159
|
|
|
162
160
|
```
|
|
161
|
+
## Contribution
|
|
162
|
+
To contribute to this project, clone or fork this repository.
|
|
163
|
+
|
|
164
|
+
There are to branches:
|
|
165
|
+
* PyPI: the main branch, for releases.
|
|
166
|
+
* TestPyPI: for pre-releases or development versions.
|
|
167
|
+
|
|
168
|
+
Pull requests from TestPyPI to PyPI will be accepted when a new release is finished.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
memorymanagement/__init__.py,sha256=Clyt9uUH0DZW36BdmWCMYNg4R2uLYYsSdsn1UgeLSJs,816
|
|
2
|
+
memorymanagement/cleaning/__init__.py,sha256=zC6dWTCTP6b-E3_Q7L45i2ZK_5DrVBbjzKT2AFuXdJk,1359
|
|
3
|
+
memorymanagement/cleaning/core.py,sha256=ya_mxI9gJDmq3zR7Y6Dw8aPQOBkMLVDNECT4X6bCke4,6539
|
|
4
|
+
memorymanagement/pointers/__init__.py,sha256=MmQnt8KtC2GTHuc-JIypjeyc_iWHJsQTvQdwZPilF34,734
|
|
5
|
+
memorymanagement/pointers/core.py,sha256=uZqQYFwevU_lfOhjcA-2L4DQWFmkxgRQgQmafsI07FA,6611
|
|
6
|
+
memorymanagement/pointers/decorators.py,sha256=NDMlexU6s123jPU0Tqny8HkMdtPsfwrzVAgjCAYpy4A,2869
|
|
7
|
+
memorymanagement-1.1.0.dist-info/licenses/LICENSE,sha256=oomqnX6WpwczxhGg1lDAUrS13YL-0NFIpomyReHWgKo,1098
|
|
8
|
+
memorymanagement-1.1.0.dist-info/METADATA,sha256=1LlTWZ4bqUBROGKh8OUfR6rGVeHwsfH3sw7eP5YqAuQ,4104
|
|
9
|
+
memorymanagement-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
memorymanagement-1.1.0.dist-info/top_level.txt,sha256=7SwrpC3BY9Cm6sqwu082DJE5SteRBira0LGqziTO7eQ,17
|
|
11
|
+
memorymanagement-1.1.0.dist-info/RECORD,,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Ricardo Werner Rivas
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ricardo Werner Rivas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
memorymanagement/__init__.py,sha256=Clyt9uUH0DZW36BdmWCMYNg4R2uLYYsSdsn1UgeLSJs,816
|
|
2
|
-
memorymanagement/cleaning/__init__.py,sha256=YnrtCkREJ01-FOGURPYQmlpWGT9TtreG40z5X0-WYJY,40
|
|
3
|
-
memorymanagement/cleaning/cleaning.py,sha256=FjwfFw5nv-zGt2UdRTUE9NNaHs8ZXsIaMsXwEm4hye8,6237
|
|
4
|
-
memorymanagement/pointers/__init__.py,sha256=mSC1rCofRafPigcndKzYncHT2KYV5NNjtOj0ixlLfjw,127
|
|
5
|
-
memorymanagement/pointers/core.py,sha256=f9FBOCUX-_lCI-zgt2J7tUJb3JdkkECcYwpdXRHAFz0,6233
|
|
6
|
-
memorymanagement/pointers/decorators.py,sha256=NDMlexU6s123jPU0Tqny8HkMdtPsfwrzVAgjCAYpy4A,2869
|
|
7
|
-
memorymanagement-1.0.0.dist-info/licenses/LICENSE,sha256=YbbIWfIjYfz9q2bm60jGAfdvdIqD96jDLvz16YsFOOk,1077
|
|
8
|
-
memorymanagement-1.0.0.dist-info/METADATA,sha256=HdZOYIds5L5rqrhEJ0sGTixBKunUWS4jrirbM74S0sA,3980
|
|
9
|
-
memorymanagement-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
memorymanagement-1.0.0.dist-info/top_level.txt,sha256=7SwrpC3BY9Cm6sqwu082DJE5SteRBira0LGqziTO7eQ,17
|
|
11
|
-
memorymanagement-1.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|