memorymanagement 1.0.0__tar.gz → 1.1.1__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.0.0 → memorymanagement-1.1.1}/LICENSE +21 -21
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/PKG-INFO +30 -12
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/README.md +26 -8
- memorymanagement-1.1.1/memorymanagement/cleaning/__init__.py +41 -0
- memorymanagement-1.0.0/memorymanagement/cleaning/cleaning.py → memorymanagement-1.1.1/memorymanagement/cleaning/core.py +12 -1
- memorymanagement-1.1.1/memorymanagement/pointers/__init__.py +15 -0
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/memorymanagement/pointers/core.py +206 -6
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/memorymanagement.egg-info/PKG-INFO +30 -12
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/memorymanagement.egg-info/SOURCES.txt +1 -1
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/setup.cfg +4 -4
- memorymanagement-1.0.0/memorymanagement/cleaning/__init__.py +0 -2
- memorymanagement-1.0.0/memorymanagement/pointers/__init__.py +0 -3
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/memorymanagement/__init__.py +0 -0
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/memorymanagement/pointers/decorators.py +0 -0
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/memorymanagement.egg-info/dependency_links.txt +0 -0
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/memorymanagement.egg-info/top_level.txt +0 -0
- {memorymanagement-1.0.0 → memorymanagement-1.1.1}/pyproject.toml +0 -0
|
@@ -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,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memorymanagement
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: Adds support for memory management
|
|
5
|
-
Home-page: https://github.com/Ricardo-Werner-Rivas/
|
|
5
|
+
Home-page: https://github.com/Ricardo-Werner-Rivas/memorymanagement/tree/PyPI
|
|
6
6
|
Author: Ricardo Werner Rivas
|
|
7
7
|
Author-email: ricardowernerrivas@gmail.com
|
|
8
8
|
License: MIT
|
|
9
|
-
Project-URL:
|
|
10
|
-
Project-URL: Repository, https://github.com/Ricardo-Werner-Rivas/
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/Ricardo-Werner-Rivas/memorymanagement/issues
|
|
10
|
+
Project-URL: Repository, https://github.com/Ricardo-Werner-Rivas/memorymanagement
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
12
|
Classifier: Operating System :: Microsoft :: Windows
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
@@ -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.
|
|
@@ -23,19 +26,14 @@ It is also possible to modify the list of flagged references through its methods
|
|
|
23
26
|
### `pointers`
|
|
24
27
|
Provides a safe implementation of pointers for Python.
|
|
25
28
|
#### Class `Pointer`
|
|
26
|
-
The pointer itself. Imitates the behaviour of C pointers.
|
|
29
|
+
The pointer itself. Imitates the behaviour of C pointers. `Pointer` points to a **reference**, not to an object stored in memory.
|
|
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
|
+
```powershell
|
|
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,23 @@ Value: 10
|
|
|
160
158
|
Value: 20
|
|
161
159
|
|
|
162
160
|
```
|
|
161
|
+
## Contribution
|
|
162
|
+
To contribute to this project fork this repository and clone your fork. Pull requests will be revised by the owner before being accepted or rejected.
|
|
163
|
+
|
|
164
|
+
There are two 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 only be done by the owner when a new release is ready.
|
|
169
|
+
|
|
170
|
+
To merge branches properly with PyPI branch in your cloned repository, you will need to have the `.gitattributes` file in the PyPI branch and execute the following commands, while in repo directory, in your PowerShell:
|
|
171
|
+
```powershell
|
|
172
|
+
git config merge.keepPyPIFiles.name "Keep README.md and setup.cfg from PyPI branch on merge"
|
|
173
|
+
git config merge.keepPyPIFiles.driver "bash -c 'cp $(git rev-parse --show-toplevel)/$3 $2'"
|
|
174
|
+
```
|
|
175
|
+
Or in your git bash terminal:
|
|
176
|
+
```bash
|
|
177
|
+
git config merge.keepPyPIFiles.name "Keep README.md and setup.cfg from PyPI branch on merge"
|
|
178
|
+
git config merge.keepPyPIFiles.driver "bash -c 'cp $(git rev-parse --show-toplevel)/$3 $2'"
|
|
179
|
+
```
|
|
180
|
+
This way, READMEs and setup files will not be overwritten in the PyPI branch.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# `memorymanagement`
|
|
2
2
|
Provides memory management support.
|
|
3
|
+
|
|
4
|
+
The only Python implementation currently supported is the one made by the **CPython** team.
|
|
5
|
+
The rest remain untested.
|
|
3
6
|
## Modules
|
|
4
7
|
### `cleaning`
|
|
5
8
|
Provides the class `Cleaner`, which allows you to flag references stored in memory to eventually erase them.
|
|
@@ -7,19 +10,14 @@ It is also possible to modify the list of flagged references through its methods
|
|
|
7
10
|
### `pointers`
|
|
8
11
|
Provides a safe implementation of pointers for Python.
|
|
9
12
|
#### Class `Pointer`
|
|
10
|
-
The pointer itself. Imitates the behaviour of C pointers.
|
|
13
|
+
The pointer itself. Imitates the behaviour of C pointers. `Pointer` points to a **reference**, not to an object stored in memory.
|
|
11
14
|
#### Decorator `pointerize`
|
|
12
15
|
Allows functions to receive pointers instead of values.
|
|
13
16
|
## Installation
|
|
14
|
-
You can install the `
|
|
15
|
-
```
|
|
17
|
+
You can install the `memorymanagement` package from **PyPI** as follows:
|
|
18
|
+
```powershell
|
|
16
19
|
pip install memorymanagement
|
|
17
20
|
```
|
|
18
|
-
You can also install the `memorymanager` package (Test PyPI versión of `memorymanager`) from TestPyPI as follows:
|
|
19
|
-
```bash
|
|
20
|
-
pip install --index-url https://test.pypi.org/simple/ memorymanager
|
|
21
|
-
```
|
|
22
|
-
For TestPyPI versión, `--no-deps` option is not needed because it has no dependencies.
|
|
23
21
|
## How to use
|
|
24
22
|
### Class `Cleaner`
|
|
25
23
|
```py
|
|
@@ -144,3 +142,23 @@ Value: 10
|
|
|
144
142
|
Value: 20
|
|
145
143
|
|
|
146
144
|
```
|
|
145
|
+
## Contribution
|
|
146
|
+
To contribute to this project fork this repository and clone your fork. Pull requests will be revised by the owner before being accepted or rejected.
|
|
147
|
+
|
|
148
|
+
There are two branches:
|
|
149
|
+
* **PyPI**: the main branch, for releases.
|
|
150
|
+
* **TestPyPI**: for pre-releases or development versions.
|
|
151
|
+
|
|
152
|
+
Pull requests from TestPyPI to PyPI will only be done by the owner when a new release is ready.
|
|
153
|
+
|
|
154
|
+
To merge branches properly with PyPI branch in your cloned repository, you will need to have the `.gitattributes` file in the PyPI branch and execute the following commands, while in repo directory, in your PowerShell:
|
|
155
|
+
```powershell
|
|
156
|
+
git config merge.keepPyPIFiles.name "Keep README.md and setup.cfg from PyPI branch on merge"
|
|
157
|
+
git config merge.keepPyPIFiles.driver "bash -c 'cp $(git rev-parse --show-toplevel)/$3 $2'"
|
|
158
|
+
```
|
|
159
|
+
Or in your git bash terminal:
|
|
160
|
+
```bash
|
|
161
|
+
git config merge.keepPyPIFiles.name "Keep README.md and setup.cfg from PyPI branch on merge"
|
|
162
|
+
git config merge.keepPyPIFiles.driver "bash -c 'cp $(git rev-parse --show-toplevel)/$3 $2'"
|
|
163
|
+
```
|
|
164
|
+
This way, READMEs and setup files will not be overwritten in the PyPI branch.
|
|
@@ -0,0 +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
|
+
"""
|
|
40
|
+
# Imports
|
|
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})"
|
|
@@ -0,0 +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
|
+
"""
|
|
13
|
+
# Import from modules
|
|
14
|
+
from .core import Pointer # Class "Pointer"
|
|
15
|
+
from .decorators import pointerize # Decorator "pointerize"
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
#*===============================================================================================================================
|
|
2
|
+
#* LEGEND
|
|
3
|
+
#! Missing
|
|
4
|
+
#? Question
|
|
5
|
+
#* Section
|
|
6
|
+
#^ Important
|
|
7
|
+
# Normal comment
|
|
8
|
+
#// Alternative or deprecated code
|
|
9
|
+
#*===============================================================================================================================
|
|
10
|
+
|
|
11
|
+
#^ The different types of comments require the "Colorful Comments Refreshed" extension for VSCode to be properly distinguished
|
|
12
|
+
|
|
13
|
+
#* IMPORTS
|
|
1
14
|
# Import "TypeVar" and "Generic"
|
|
2
15
|
from typing import TypeVar,Generic
|
|
3
16
|
# Import "modules" from "sys" package
|
|
@@ -5,10 +18,9 @@ from sys import modules
|
|
|
5
18
|
# Import "currentframe" from "inspect" package
|
|
6
19
|
from inspect import currentframe
|
|
7
20
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class Pointer(Generic[object_type]):
|
|
21
|
+
#* MAIN CLASS
|
|
22
|
+
# Define the class "Pointer" with generic type
|
|
23
|
+
class Pointer(Generic[TypeVar("Any")]):
|
|
12
24
|
"""
|
|
13
25
|
Implements pointers in Python for both mutable (though unneded) and non-mutable objects.
|
|
14
26
|
These pointers are completely safe and do not work internally as C's pointers, they are just an imitation of their behaviour.
|
|
@@ -66,7 +78,6 @@ class Pointer(Generic[object_type]):
|
|
|
66
78
|
self._value=value
|
|
67
79
|
self._vars_dict=vars_dict
|
|
68
80
|
self._attr=attr
|
|
69
|
-
name=None
|
|
70
81
|
name=[]
|
|
71
82
|
for key,v in vars_dict.items():
|
|
72
83
|
try:
|
|
@@ -90,7 +101,11 @@ class Pointer(Generic[object_type]):
|
|
|
90
101
|
name=None
|
|
91
102
|
self._name=name
|
|
92
103
|
return
|
|
104
|
+
|
|
105
|
+
#* PROPERTIES
|
|
106
|
+
# Value
|
|
93
107
|
@property
|
|
108
|
+
# Getter
|
|
94
109
|
def value(self):
|
|
95
110
|
if self._attr:
|
|
96
111
|
if self._name and self._name not in list(self._vars_dict):
|
|
@@ -107,6 +122,7 @@ class Pointer(Generic[object_type]):
|
|
|
107
122
|
if self._value is not self._vars_dict[self._name]:
|
|
108
123
|
self._value=self._vars_dict[self._name]
|
|
109
124
|
return self._value
|
|
125
|
+
# Setter
|
|
110
126
|
@value.setter
|
|
111
127
|
def value(self,value):
|
|
112
128
|
if self._attr:
|
|
@@ -116,6 +132,7 @@ class Pointer(Generic[object_type]):
|
|
|
116
132
|
if self._name and value is not self._vars_dict[self._name]:
|
|
117
133
|
self._vars_dict[self._name]=value
|
|
118
134
|
return
|
|
135
|
+
# Deleter
|
|
119
136
|
@value.deleter
|
|
120
137
|
def value(self):
|
|
121
138
|
if self._attr:
|
|
@@ -124,4 +141,187 @@ class Pointer(Generic[object_type]):
|
|
|
124
141
|
del self._value
|
|
125
142
|
if self._name:
|
|
126
143
|
del self._vars_dict[self._name]
|
|
127
|
-
return
|
|
144
|
+
return
|
|
145
|
+
|
|
146
|
+
#* INDEXATION
|
|
147
|
+
# Getter
|
|
148
|
+
def __getitem__(self,index):
|
|
149
|
+
return self.value[index]
|
|
150
|
+
# Setter
|
|
151
|
+
def __setitem__(self,index,value):
|
|
152
|
+
self.value[index]=value
|
|
153
|
+
return
|
|
154
|
+
# Deleter
|
|
155
|
+
def __delitem__(self,index):
|
|
156
|
+
del self.value[index]
|
|
157
|
+
return
|
|
158
|
+
|
|
159
|
+
#* ARITHMETIC OPERATIONS
|
|
160
|
+
# Addition
|
|
161
|
+
def __add__(self,value):
|
|
162
|
+
if isinstance(value,Pointer):
|
|
163
|
+
return self.value+value.value
|
|
164
|
+
else:
|
|
165
|
+
return self.value+value
|
|
166
|
+
# Difference
|
|
167
|
+
def __sub__(self,value):
|
|
168
|
+
if isinstance(value,Pointer):
|
|
169
|
+
return self.value-value.value
|
|
170
|
+
else:
|
|
171
|
+
return self.value-value
|
|
172
|
+
# Multiplication
|
|
173
|
+
def __mul__(self,value):
|
|
174
|
+
if isinstance(value,Pointer):
|
|
175
|
+
return self.value*value.value
|
|
176
|
+
else:
|
|
177
|
+
return self.value*value
|
|
178
|
+
# Fraction
|
|
179
|
+
def __truediv__(self,value):
|
|
180
|
+
if isinstance(value,Pointer):
|
|
181
|
+
return self.value/value.value
|
|
182
|
+
else:
|
|
183
|
+
return self.value/value
|
|
184
|
+
# Integer division
|
|
185
|
+
def __floordiv__(self,value):
|
|
186
|
+
if isinstance(value,Pointer):
|
|
187
|
+
return self.value//value.value
|
|
188
|
+
else:
|
|
189
|
+
return self.value//value
|
|
190
|
+
# Module
|
|
191
|
+
def __mod__(self,value):
|
|
192
|
+
if isinstance(value,Pointer):
|
|
193
|
+
return self.value%value.value
|
|
194
|
+
else:
|
|
195
|
+
return self.value%value
|
|
196
|
+
# Power
|
|
197
|
+
def __pow__(self,value):
|
|
198
|
+
if isinstance(value,Pointer):
|
|
199
|
+
return self.value**value.value
|
|
200
|
+
else:
|
|
201
|
+
return self.value**value
|
|
202
|
+
|
|
203
|
+
#* REFLEXED ARITHMETIC METHODS
|
|
204
|
+
# Addition
|
|
205
|
+
def __radd__(self,value):
|
|
206
|
+
return value+self.value
|
|
207
|
+
# Difference
|
|
208
|
+
def __rsub__(self,value):
|
|
209
|
+
return value-self.value
|
|
210
|
+
# Multiplication
|
|
211
|
+
def __rmul__(self,value):
|
|
212
|
+
return value*self.value
|
|
213
|
+
# Fraction
|
|
214
|
+
def __rtruediv__(self,value):
|
|
215
|
+
return value/self.value
|
|
216
|
+
# Integer division
|
|
217
|
+
def __rfloordiv__(self,value):
|
|
218
|
+
return value//self.value
|
|
219
|
+
# Module
|
|
220
|
+
def __rmod__(self,value):
|
|
221
|
+
return value%self.value
|
|
222
|
+
# Power
|
|
223
|
+
def __rpow__(self,value):
|
|
224
|
+
return value**self.value
|
|
225
|
+
|
|
226
|
+
#* IN-PLACE ARITHMETIC METHODS
|
|
227
|
+
# Addition
|
|
228
|
+
def __iadd__(self,value):
|
|
229
|
+
self.value=self.value+value
|
|
230
|
+
return self
|
|
231
|
+
# Difference
|
|
232
|
+
def __isub__(self,value):
|
|
233
|
+
self.value=self.value-value
|
|
234
|
+
return self
|
|
235
|
+
# Multiplication
|
|
236
|
+
def __imul__(self,value):
|
|
237
|
+
self.value=self.value*value
|
|
238
|
+
return self
|
|
239
|
+
# Fraction
|
|
240
|
+
def __itruediv__(self,value):
|
|
241
|
+
self.value=self.value/value
|
|
242
|
+
return self
|
|
243
|
+
# Integer division
|
|
244
|
+
def __ifloordiv__(self,value):
|
|
245
|
+
self.value=self.value//value
|
|
246
|
+
return self
|
|
247
|
+
# Module
|
|
248
|
+
def __imod__(self,value):
|
|
249
|
+
self.value=self.value%value
|
|
250
|
+
return self
|
|
251
|
+
def __ipow__(self,value):
|
|
252
|
+
self.value=self.value**value
|
|
253
|
+
return self
|
|
254
|
+
|
|
255
|
+
#* COMPARATIVE METHODS
|
|
256
|
+
# Equality
|
|
257
|
+
def __eq__(self,value):
|
|
258
|
+
if isinstance(value,Pointer):
|
|
259
|
+
return self.value==value.value
|
|
260
|
+
else:
|
|
261
|
+
return self.value==value
|
|
262
|
+
# Inequality
|
|
263
|
+
def __ne__(self,value):
|
|
264
|
+
if isinstance(value,Pointer):
|
|
265
|
+
return self.value!=value.value
|
|
266
|
+
else:
|
|
267
|
+
return self.value!=value
|
|
268
|
+
# Lower than
|
|
269
|
+
def __lt__(self,value):
|
|
270
|
+
if isinstance(value,Pointer):
|
|
271
|
+
return self.value<value.value
|
|
272
|
+
else:
|
|
273
|
+
return self.value<value
|
|
274
|
+
# Lower or equal
|
|
275
|
+
def __le__(self,value):
|
|
276
|
+
if isinstance(value,Pointer):
|
|
277
|
+
return self.value<=value.value
|
|
278
|
+
else:
|
|
279
|
+
return self.value<=value
|
|
280
|
+
# Greater than
|
|
281
|
+
def __gt__(self,value):
|
|
282
|
+
if isinstance(value,Pointer):
|
|
283
|
+
return self.value>value.value
|
|
284
|
+
else:
|
|
285
|
+
return self.value>value
|
|
286
|
+
# Greater or equal
|
|
287
|
+
def __ge__(self,value):
|
|
288
|
+
if isinstance(value,Pointer):
|
|
289
|
+
return self.value>=value.value
|
|
290
|
+
else:
|
|
291
|
+
return self.value>=value
|
|
292
|
+
|
|
293
|
+
#* UNARY METHODS
|
|
294
|
+
# Negative
|
|
295
|
+
def __neg__(self):
|
|
296
|
+
return Pointer(-self.value)
|
|
297
|
+
# Positive
|
|
298
|
+
def __pos__(self):
|
|
299
|
+
return Pointer(+self.value)
|
|
300
|
+
# Absolute value
|
|
301
|
+
def __abs__(self):
|
|
302
|
+
return Pointer(abs(self.value))
|
|
303
|
+
|
|
304
|
+
#* LENGTH
|
|
305
|
+
# Length
|
|
306
|
+
def __len__(self):
|
|
307
|
+
return len(self.value)
|
|
308
|
+
|
|
309
|
+
#* TRANSFORMATION METHODS
|
|
310
|
+
# __int__
|
|
311
|
+
def __int__(self):
|
|
312
|
+
return int(self.value)
|
|
313
|
+
def __float__(self):
|
|
314
|
+
return float(self.value)
|
|
315
|
+
def __index__(self):
|
|
316
|
+
return self.value
|
|
317
|
+
|
|
318
|
+
#* SCREEN
|
|
319
|
+
# Representation
|
|
320
|
+
def __repr__(self):
|
|
321
|
+
return f"{self.__class__.__name__}({self.value})"
|
|
322
|
+
# HTML representation
|
|
323
|
+
def _repr_html_(self):
|
|
324
|
+
return f"<p>{self.value}</p>"
|
|
325
|
+
# Printing
|
|
326
|
+
def __str__(self):
|
|
327
|
+
return str(self.value)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memorymanagement
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: Adds support for memory management
|
|
5
|
-
Home-page: https://github.com/Ricardo-Werner-Rivas/
|
|
5
|
+
Home-page: https://github.com/Ricardo-Werner-Rivas/memorymanagement/tree/PyPI
|
|
6
6
|
Author: Ricardo Werner Rivas
|
|
7
7
|
Author-email: ricardowernerrivas@gmail.com
|
|
8
8
|
License: MIT
|
|
9
|
-
Project-URL:
|
|
10
|
-
Project-URL: Repository, https://github.com/Ricardo-Werner-Rivas/
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/Ricardo-Werner-Rivas/memorymanagement/issues
|
|
10
|
+
Project-URL: Repository, https://github.com/Ricardo-Werner-Rivas/memorymanagement
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
12
|
Classifier: Operating System :: Microsoft :: Windows
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
@@ -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.
|
|
@@ -23,19 +26,14 @@ It is also possible to modify the list of flagged references through its methods
|
|
|
23
26
|
### `pointers`
|
|
24
27
|
Provides a safe implementation of pointers for Python.
|
|
25
28
|
#### Class `Pointer`
|
|
26
|
-
The pointer itself. Imitates the behaviour of C pointers.
|
|
29
|
+
The pointer itself. Imitates the behaviour of C pointers. `Pointer` points to a **reference**, not to an object stored in memory.
|
|
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
|
+
```powershell
|
|
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,23 @@ Value: 10
|
|
|
160
158
|
Value: 20
|
|
161
159
|
|
|
162
160
|
```
|
|
161
|
+
## Contribution
|
|
162
|
+
To contribute to this project fork this repository and clone your fork. Pull requests will be revised by the owner before being accepted or rejected.
|
|
163
|
+
|
|
164
|
+
There are two 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 only be done by the owner when a new release is ready.
|
|
169
|
+
|
|
170
|
+
To merge branches properly with PyPI branch in your cloned repository, you will need to have the `.gitattributes` file in the PyPI branch and execute the following commands, while in repo directory, in your PowerShell:
|
|
171
|
+
```powershell
|
|
172
|
+
git config merge.keepPyPIFiles.name "Keep README.md and setup.cfg from PyPI branch on merge"
|
|
173
|
+
git config merge.keepPyPIFiles.driver "bash -c 'cp $(git rev-parse --show-toplevel)/$3 $2'"
|
|
174
|
+
```
|
|
175
|
+
Or in your git bash terminal:
|
|
176
|
+
```bash
|
|
177
|
+
git config merge.keepPyPIFiles.name "Keep README.md and setup.cfg from PyPI branch on merge"
|
|
178
|
+
git config merge.keepPyPIFiles.driver "bash -c 'cp $(git rev-parse --show-toplevel)/$3 $2'"
|
|
179
|
+
```
|
|
180
|
+
This way, READMEs and setup files will not be overwritten in the PyPI branch.
|
|
@@ -8,7 +8,7 @@ memorymanagement.egg-info/SOURCES.txt
|
|
|
8
8
|
memorymanagement.egg-info/dependency_links.txt
|
|
9
9
|
memorymanagement.egg-info/top_level.txt
|
|
10
10
|
memorymanagement/cleaning/__init__.py
|
|
11
|
-
memorymanagement/cleaning/
|
|
11
|
+
memorymanagement/cleaning/core.py
|
|
12
12
|
memorymanagement/pointers/__init__.py
|
|
13
13
|
memorymanagement/pointers/core.py
|
|
14
14
|
memorymanagement/pointers/decorators.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = memorymanagement
|
|
3
|
-
version = 1.
|
|
3
|
+
version = 1.1.1
|
|
4
4
|
author = Ricardo Werner Rivas
|
|
5
5
|
author_email = ricardowernerrivas@gmail.com
|
|
6
6
|
description = Adds support for memory management
|
|
@@ -8,10 +8,10 @@ long_description = file:README.md
|
|
|
8
8
|
long_description_content_type = text/markdown
|
|
9
9
|
license = MIT
|
|
10
10
|
license_files = LICENSE
|
|
11
|
-
url = https://github.com/Ricardo-Werner-Rivas/
|
|
11
|
+
url = https://github.com/Ricardo-Werner-Rivas/memorymanagement/tree/PyPI
|
|
12
12
|
project_urls =
|
|
13
|
-
|
|
14
|
-
Repository=https://github.com/Ricardo-Werner-Rivas/
|
|
13
|
+
Bug Tracker=https://github.com/Ricardo-Werner-Rivas/memorymanagement/issues
|
|
14
|
+
Repository=https://github.com/Ricardo-Werner-Rivas/memorymanagement
|
|
15
15
|
classifiers =
|
|
16
16
|
Programming Language :: Python
|
|
17
17
|
Operating System :: Microsoft :: Windows
|
|
File without changes
|
|
File without changes
|
{memorymanagement-1.0.0 → memorymanagement-1.1.1}/memorymanagement.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|