memorymanagement 1.1.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.
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memorymanagement
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: Adds support for memory management
5
- Home-page: https://github.com/Ricardo-Werner-Rivas/python-memory-management/tree/PyPI
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: Bug Tracker, https://github.com/Ricardo-Werner-Rivas/python-memory-management/issues
10
- Project-URL: Repository, https://github.com/Ricardo-Werner-Rivas/python-memory-management
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
@@ -26,12 +26,12 @@ It is also possible to modify the list of flagged references through its methods
26
26
  ### `pointers`
27
27
  Provides a safe implementation of pointers for Python.
28
28
  #### Class `Pointer`
29
- The pointer itself. Imitates the behaviour of C pointers. This pointer points to a reference, not to an object stored in memory.
29
+ The pointer itself. Imitates the behaviour of C pointers. `Pointer` points to a **reference**, not to an object stored in memory.
30
30
  #### Decorator `pointerize`
31
31
  Allows functions to receive pointers instead of values.
32
32
  ## Installation
33
- You can install the `memorymanagement` package from PyPI as follows:
34
- ```ps
33
+ You can install the `memorymanagement` package from **PyPI** as follows:
34
+ ```powershell
35
35
  pip install memorymanagement
36
36
  ```
37
37
  ## How to use
@@ -159,10 +159,22 @@ Value: 20
159
159
 
160
160
  ```
161
161
  ## Contribution
162
- To contribute to this project, clone or fork this repository.
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
163
 
164
- There are to branches:
165
- * PyPI: the main branch, for releases.
166
- * TestPyPI: for pre-releases or development versions.
164
+ There are two branches:
165
+ * **PyPI**: the main branch, for releases.
166
+ * **TestPyPI**: for pre-releases or development versions.
167
167
 
168
- Pull requests from TestPyPI to PyPI will be accepted when a new release is finished.
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.
@@ -10,12 +10,12 @@ It is also possible to modify the list of flagged references through its methods
10
10
  ### `pointers`
11
11
  Provides a safe implementation of pointers for Python.
12
12
  #### Class `Pointer`
13
- The pointer itself. Imitates the behaviour of C pointers. This pointer points to a reference, not to an object stored in memory.
13
+ The pointer itself. Imitates the behaviour of C pointers. `Pointer` points to a **reference**, not to an object stored in memory.
14
14
  #### Decorator `pointerize`
15
15
  Allows functions to receive pointers instead of values.
16
16
  ## Installation
17
- You can install the `memorymanagement` package from PyPI as follows:
18
- ```ps
17
+ You can install the `memorymanagement` package from **PyPI** as follows:
18
+ ```powershell
19
19
  pip install memorymanagement
20
20
  ```
21
21
  ## How to use
@@ -143,10 +143,22 @@ Value: 20
143
143
 
144
144
  ```
145
145
  ## Contribution
146
- To contribute to this project, clone or fork this repository.
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
147
 
148
- There are to branches:
149
- * PyPI: the main branch, for releases.
150
- * TestPyPI: for pre-releases or development versions.
148
+ There are two branches:
149
+ * **PyPI**: the main branch, for releases.
150
+ * **TestPyPI**: for pre-releases or development versions.
151
151
 
152
- Pull requests from TestPyPI to PyPI will be accepted when a new release is finished.
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.
@@ -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
- # Create new generic type
9
- object_type=TypeVar("object_type")
10
- # Define the class "Pointer"
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:
@@ -125,15 +142,186 @@ class Pointer(Generic[object_type]):
125
142
  if self._name:
126
143
  del self._vars_dict[self._name]
127
144
  return
145
+
146
+ #* INDEXATION
147
+ # Getter
128
148
  def __getitem__(self,index):
129
149
  return self.value[index]
150
+ # Setter
130
151
  def __setitem__(self,index,value):
131
152
  self.value[index]=value
132
153
  return
154
+ # Deleter
133
155
  def __delitem__(self,index):
134
156
  del self.value[index]
135
157
  return
136
- def __str__(self):
137
- return str(self.value)
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
138
320
  def __repr__(self):
139
- return f"{self.__class__.__name__}({self.value})"
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.1.0
3
+ Version: 1.1.1
4
4
  Summary: Adds support for memory management
5
- Home-page: https://github.com/Ricardo-Werner-Rivas/python-memory-management/tree/PyPI
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: Bug Tracker, https://github.com/Ricardo-Werner-Rivas/python-memory-management/issues
10
- Project-URL: Repository, https://github.com/Ricardo-Werner-Rivas/python-memory-management
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
@@ -26,12 +26,12 @@ It is also possible to modify the list of flagged references through its methods
26
26
  ### `pointers`
27
27
  Provides a safe implementation of pointers for Python.
28
28
  #### Class `Pointer`
29
- The pointer itself. Imitates the behaviour of C pointers. This pointer points to a reference, not to an object stored in memory.
29
+ The pointer itself. Imitates the behaviour of C pointers. `Pointer` points to a **reference**, not to an object stored in memory.
30
30
  #### Decorator `pointerize`
31
31
  Allows functions to receive pointers instead of values.
32
32
  ## Installation
33
- You can install the `memorymanagement` package from PyPI as follows:
34
- ```ps
33
+ You can install the `memorymanagement` package from **PyPI** as follows:
34
+ ```powershell
35
35
  pip install memorymanagement
36
36
  ```
37
37
  ## How to use
@@ -159,10 +159,22 @@ Value: 20
159
159
 
160
160
  ```
161
161
  ## Contribution
162
- To contribute to this project, clone or fork this repository.
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
163
 
164
- There are to branches:
165
- * PyPI: the main branch, for releases.
166
- * TestPyPI: for pre-releases or development versions.
164
+ There are two branches:
165
+ * **PyPI**: the main branch, for releases.
166
+ * **TestPyPI**: for pre-releases or development versions.
167
167
 
168
- Pull requests from TestPyPI to PyPI will be accepted when a new release is finished.
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,6 +1,6 @@
1
1
  [metadata]
2
2
  name = memorymanagement
3
- version = 1.1.0
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/python-memory-management/tree/PyPI
11
+ url = https://github.com/Ricardo-Werner-Rivas/memorymanagement/tree/PyPI
12
12
  project_urls =
13
- Bug Tracker=https://github.com/Ricardo-Werner-Rivas/python-memory-management/issues
14
- Repository=https://github.com/Ricardo-Werner-Rivas/python-memory-management
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