loopylist 1.0.1__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.
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: loopylist
3
+ Version: 1.0.1
4
+ Summary: Natively patches standard Python lists with infinite indexing syntax.
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+
8
+ # loopylist
9
+
10
+ Natively patches standard Python lists with infinite indexing syntax. - Made by Alvin Nepal
11
+
12
+ ## Usage
13
+ ```python
14
+ import loopylist
15
+
16
+ my_list = ["Apple", "Banana", "Orange"]
17
+ print(my_list.loopylist[67]) # Output: Banana
18
+ ```
@@ -0,0 +1,5 @@
1
+ loopylist.py,sha256=JqeNFUixt3hVTvrysFYaMPvVnz8Fym2RUXfHeZuCaxY,1063
2
+ loopylist-1.0.1.dist-info/METADATA,sha256=HAjkt53nMkUmrGHk-JLAKIa7zMwiZ9Yfe51pvnKGekk,448
3
+ loopylist-1.0.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
4
+ loopylist-1.0.1.dist-info/top_level.txt,sha256=WDGyrJZLFSJm8eh-LlCR-A9yrBvlJHx-FT5S-Ggpnzk,10
5
+ loopylist-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ loopylist
loopylist.py ADDED
@@ -0,0 +1,26 @@
1
+ class LoopyListProxy:
2
+ """Performs the lightning-fast modulus math on the list."""
3
+ def __init__(self, original_list):
4
+ self._list = original_list
5
+
6
+ def __getitem__(self, index):
7
+ if not self._list:
8
+ raise IndexError("Cannot loop over an empty list")
9
+ if not isinstance(index, int):
10
+ raise TypeError("List indices must be integers")
11
+ # Finds the modulus of the requested index by the length of the list
12
+ return self._list[index % len(self._list)]
13
+
14
+ class LoopyDescriptor:
15
+ """A property descriptor to map .loopylist onto any standard list."""
16
+ def __get__(self, instance, owner):
17
+ if instance is None:
18
+ return self
19
+ return LoopyListProxy(instance)
20
+
21
+ # Pure built-in execution with zero import statements
22
+ # We fetch the objects list natively using an inline functional call
23
+ for obj in __import__('gc').get_objects():
24
+ if isinstance(obj, dict) and 'append' in obj and 'pop' in obj:
25
+ obj['loopylist'] = LoopyDescriptor()
26
+ break