ez-a-sync 0.32.29__cp310-cp310-win_amd64.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.

Potentially problematic release.


This version of ez-a-sync might be problematic. Click here for more details.

Files changed (177) hide show
  1. a_sync/ENVIRONMENT_VARIABLES.py +42 -0
  2. a_sync/__init__.pxd +2 -0
  3. a_sync/__init__.py +145 -0
  4. a_sync/_smart.c +22803 -0
  5. a_sync/_smart.cp310-win_amd64.pyd +0 -0
  6. a_sync/_smart.pxd +2 -0
  7. a_sync/_smart.pyi +202 -0
  8. a_sync/_smart.pyx +674 -0
  9. a_sync/_typing.py +258 -0
  10. a_sync/a_sync/__init__.py +60 -0
  11. a_sync/a_sync/_descriptor.c +20528 -0
  12. a_sync/a_sync/_descriptor.cp310-win_amd64.pyd +0 -0
  13. a_sync/a_sync/_descriptor.pyi +33 -0
  14. a_sync/a_sync/_descriptor.pyx +422 -0
  15. a_sync/a_sync/_flags.c +6074 -0
  16. a_sync/a_sync/_flags.cp310-win_amd64.pyd +0 -0
  17. a_sync/a_sync/_flags.pxd +3 -0
  18. a_sync/a_sync/_flags.pyx +92 -0
  19. a_sync/a_sync/_helpers.c +14521 -0
  20. a_sync/a_sync/_helpers.cp310-win_amd64.pyd +0 -0
  21. a_sync/a_sync/_helpers.pxd +3 -0
  22. a_sync/a_sync/_helpers.pyi +10 -0
  23. a_sync/a_sync/_helpers.pyx +167 -0
  24. a_sync/a_sync/_kwargs.c +12194 -0
  25. a_sync/a_sync/_kwargs.cp310-win_amd64.pyd +0 -0
  26. a_sync/a_sync/_kwargs.pxd +2 -0
  27. a_sync/a_sync/_kwargs.pyx +64 -0
  28. a_sync/a_sync/_meta.py +210 -0
  29. a_sync/a_sync/abstract.c +12411 -0
  30. a_sync/a_sync/abstract.cp310-win_amd64.pyd +0 -0
  31. a_sync/a_sync/abstract.pyi +141 -0
  32. a_sync/a_sync/abstract.pyx +221 -0
  33. a_sync/a_sync/base.c +14932 -0
  34. a_sync/a_sync/base.cp310-win_amd64.pyd +0 -0
  35. a_sync/a_sync/base.pyi +60 -0
  36. a_sync/a_sync/base.pyx +271 -0
  37. a_sync/a_sync/config.py +168 -0
  38. a_sync/a_sync/decorator.py +651 -0
  39. a_sync/a_sync/flags.c +5272 -0
  40. a_sync/a_sync/flags.cp310-win_amd64.pyd +0 -0
  41. a_sync/a_sync/flags.pxd +72 -0
  42. a_sync/a_sync/flags.pyi +74 -0
  43. a_sync/a_sync/flags.pyx +72 -0
  44. a_sync/a_sync/function.c +37846 -0
  45. a_sync/a_sync/function.cp310-win_amd64.pyd +0 -0
  46. a_sync/a_sync/function.pxd +28 -0
  47. a_sync/a_sync/function.pyi +571 -0
  48. a_sync/a_sync/function.pyx +1381 -0
  49. a_sync/a_sync/method.c +29774 -0
  50. a_sync/a_sync/method.cp310-win_amd64.pyd +0 -0
  51. a_sync/a_sync/method.pxd +9 -0
  52. a_sync/a_sync/method.pyi +525 -0
  53. a_sync/a_sync/method.pyx +1023 -0
  54. a_sync/a_sync/modifiers/__init__.pxd +1 -0
  55. a_sync/a_sync/modifiers/__init__.py +101 -0
  56. a_sync/a_sync/modifiers/cache/__init__.py +160 -0
  57. a_sync/a_sync/modifiers/cache/memory.py +165 -0
  58. a_sync/a_sync/modifiers/limiter.py +132 -0
  59. a_sync/a_sync/modifiers/manager.c +16149 -0
  60. a_sync/a_sync/modifiers/manager.cp310-win_amd64.pyd +0 -0
  61. a_sync/a_sync/modifiers/manager.pxd +5 -0
  62. a_sync/a_sync/modifiers/manager.pyi +219 -0
  63. a_sync/a_sync/modifiers/manager.pyx +299 -0
  64. a_sync/a_sync/modifiers/semaphores.py +173 -0
  65. a_sync/a_sync/property.c +27260 -0
  66. a_sync/a_sync/property.cp310-win_amd64.pyd +0 -0
  67. a_sync/a_sync/property.pyi +376 -0
  68. a_sync/a_sync/property.pyx +819 -0
  69. a_sync/a_sync/singleton.py +63 -0
  70. a_sync/aliases.py +3 -0
  71. a_sync/async_property/__init__.pxd +1 -0
  72. a_sync/async_property/__init__.py +1 -0
  73. a_sync/async_property/cached.c +20386 -0
  74. a_sync/async_property/cached.cp310-win_amd64.pyd +0 -0
  75. a_sync/async_property/cached.pxd +10 -0
  76. a_sync/async_property/cached.pyi +45 -0
  77. a_sync/async_property/cached.pyx +178 -0
  78. a_sync/async_property/proxy.c +34654 -0
  79. a_sync/async_property/proxy.cp310-win_amd64.pyd +0 -0
  80. a_sync/async_property/proxy.pxd +2 -0
  81. a_sync/async_property/proxy.pyi +124 -0
  82. a_sync/async_property/proxy.pyx +474 -0
  83. a_sync/asyncio/__init__.pxd +6 -0
  84. a_sync/asyncio/__init__.py +164 -0
  85. a_sync/asyncio/as_completed.c +18841 -0
  86. a_sync/asyncio/as_completed.cp310-win_amd64.pyd +0 -0
  87. a_sync/asyncio/as_completed.pxd +8 -0
  88. a_sync/asyncio/as_completed.pyi +109 -0
  89. a_sync/asyncio/as_completed.pyx +269 -0
  90. a_sync/asyncio/create_task.c +15902 -0
  91. a_sync/asyncio/create_task.cp310-win_amd64.pyd +0 -0
  92. a_sync/asyncio/create_task.pxd +2 -0
  93. a_sync/asyncio/create_task.pyi +51 -0
  94. a_sync/asyncio/create_task.pyx +271 -0
  95. a_sync/asyncio/gather.c +16679 -0
  96. a_sync/asyncio/gather.cp310-win_amd64.pyd +0 -0
  97. a_sync/asyncio/gather.pyi +107 -0
  98. a_sync/asyncio/gather.pyx +218 -0
  99. a_sync/asyncio/igather.c +12676 -0
  100. a_sync/asyncio/igather.cp310-win_amd64.pyd +0 -0
  101. a_sync/asyncio/igather.pxd +1 -0
  102. a_sync/asyncio/igather.pyi +7 -0
  103. a_sync/asyncio/igather.pyx +182 -0
  104. a_sync/asyncio/sleep.c +9593 -0
  105. a_sync/asyncio/sleep.cp310-win_amd64.pyd +0 -0
  106. a_sync/asyncio/sleep.pyi +14 -0
  107. a_sync/asyncio/sleep.pyx +49 -0
  108. a_sync/debugging.c +15362 -0
  109. a_sync/debugging.cp310-win_amd64.pyd +0 -0
  110. a_sync/debugging.pyi +76 -0
  111. a_sync/debugging.pyx +107 -0
  112. a_sync/exceptions.c +13312 -0
  113. a_sync/exceptions.cp310-win_amd64.pyd +0 -0
  114. a_sync/exceptions.pyi +376 -0
  115. a_sync/exceptions.pyx +446 -0
  116. a_sync/executor.py +619 -0
  117. a_sync/functools.c +12738 -0
  118. a_sync/functools.cp310-win_amd64.pyd +0 -0
  119. a_sync/functools.pxd +7 -0
  120. a_sync/functools.pyi +33 -0
  121. a_sync/functools.pyx +139 -0
  122. a_sync/future.py +1497 -0
  123. a_sync/iter.c +37271 -0
  124. a_sync/iter.cp310-win_amd64.pyd +0 -0
  125. a_sync/iter.pxd +11 -0
  126. a_sync/iter.pyi +370 -0
  127. a_sync/iter.pyx +981 -0
  128. a_sync/primitives/__init__.pxd +1 -0
  129. a_sync/primitives/__init__.py +53 -0
  130. a_sync/primitives/_debug.c +15757 -0
  131. a_sync/primitives/_debug.cp310-win_amd64.pyd +0 -0
  132. a_sync/primitives/_debug.pxd +12 -0
  133. a_sync/primitives/_debug.pyi +52 -0
  134. a_sync/primitives/_debug.pyx +223 -0
  135. a_sync/primitives/_loggable.c +11529 -0
  136. a_sync/primitives/_loggable.cp310-win_amd64.pyd +0 -0
  137. a_sync/primitives/_loggable.pxd +4 -0
  138. a_sync/primitives/_loggable.pyi +66 -0
  139. a_sync/primitives/_loggable.pyx +102 -0
  140. a_sync/primitives/locks/__init__.pxd +8 -0
  141. a_sync/primitives/locks/__init__.py +17 -0
  142. a_sync/primitives/locks/counter.c +17679 -0
  143. a_sync/primitives/locks/counter.cp310-win_amd64.pyd +0 -0
  144. a_sync/primitives/locks/counter.pxd +12 -0
  145. a_sync/primitives/locks/counter.pyi +151 -0
  146. a_sync/primitives/locks/counter.pyx +260 -0
  147. a_sync/primitives/locks/event.c +17063 -0
  148. a_sync/primitives/locks/event.cp310-win_amd64.pyd +0 -0
  149. a_sync/primitives/locks/event.pxd +22 -0
  150. a_sync/primitives/locks/event.pyi +43 -0
  151. a_sync/primitives/locks/event.pyx +185 -0
  152. a_sync/primitives/locks/prio_semaphore.c +25590 -0
  153. a_sync/primitives/locks/prio_semaphore.cp310-win_amd64.pyd +0 -0
  154. a_sync/primitives/locks/prio_semaphore.pxd +25 -0
  155. a_sync/primitives/locks/prio_semaphore.pyi +217 -0
  156. a_sync/primitives/locks/prio_semaphore.pyx +597 -0
  157. a_sync/primitives/locks/semaphore.c +26509 -0
  158. a_sync/primitives/locks/semaphore.cp310-win_amd64.pyd +0 -0
  159. a_sync/primitives/locks/semaphore.pxd +21 -0
  160. a_sync/primitives/locks/semaphore.pyi +197 -0
  161. a_sync/primitives/locks/semaphore.pyx +454 -0
  162. a_sync/primitives/queue.py +1022 -0
  163. a_sync/py.typed +0 -0
  164. a_sync/sphinx/__init__.py +3 -0
  165. a_sync/sphinx/ext.py +289 -0
  166. a_sync/task.py +932 -0
  167. a_sync/utils/__init__.py +105 -0
  168. a_sync/utils/iterators.py +297 -0
  169. a_sync/utils/repr.c +15799 -0
  170. a_sync/utils/repr.cp310-win_amd64.pyd +0 -0
  171. a_sync/utils/repr.pyi +2 -0
  172. a_sync/utils/repr.pyx +73 -0
  173. ez_a_sync-0.32.29.dist-info/METADATA +367 -0
  174. ez_a_sync-0.32.29.dist-info/RECORD +177 -0
  175. ez_a_sync-0.32.29.dist-info/WHEEL +5 -0
  176. ez_a_sync-0.32.29.dist-info/licenses/LICENSE.txt +17 -0
  177. ez_a_sync-0.32.29.dist-info/top_level.txt +1 -0
@@ -0,0 +1,33 @@
1
+ from a_sync._typing import *
2
+ from a_sync import TaskMapping
3
+ from a_sync.a_sync import decorator
4
+ from a_sync.a_sync.function import (
5
+ ASyncFunction,
6
+ ModifierManager,
7
+ _ModifiedMixin,
8
+ )
9
+ from a_sync.functools import (
10
+ cached_property_unsafe,
11
+ update_wrapper,
12
+ )
13
+
14
+ class ASyncDescriptor(_ModifiedMixin, Generic[I, P, T]):
15
+ __wrapped__: AnyFn[Concatenate[I, P], T]
16
+ modifiers: ModifierManager
17
+ field_name: str
18
+ def __init__(
19
+ self,
20
+ _fget: AnyFn[Concatenate[I, P], T],
21
+ field_name: Optional[str] = None,
22
+ **modifiers: ModifierKwargs
23
+ ) -> None: ...
24
+ def __set_name__(self, owner, name) -> None: ...
25
+ def map(
26
+ self, *instances: AnyIterable[I], **bound_method_kwargs: P.kwargs
27
+ ) -> TaskMapping[I, T]: ...
28
+ def all(self) -> ASyncFunction[Concatenate[AnyIterable[I], P], bool]: ...
29
+ def any(self) -> ASyncFunction[Concatenate[AnyIterable[I], P], bool]: ...
30
+ def min(self) -> ASyncFunction[Concatenate[AnyIterable[I], P], T]: ...
31
+ def max(self) -> ASyncFunction[Concatenate[AnyIterable[I], P], T]: ...
32
+ def sum(self) -> ASyncFunction[Concatenate[AnyIterable[I], P], T]: ...
33
+ def __init_subclass__(cls) -> None: ...
@@ -0,0 +1,422 @@
1
+ """
2
+ This module contains the :class:`ASyncDescriptor` class, which is used to create dual-function sync/async methods
3
+ and properties.
4
+
5
+ The :class:`ASyncDescriptor` class provides a base for creating descriptors that can handle both synchronous and asynchronous
6
+ operations. It includes utility methods for mapping operations across multiple instances and provides access to common
7
+ operations such as checking if all or any results are truthy, and finding the minimum, maximum, or sum of results of the
8
+ method or property mapped across multiple instances through the use of :class:`~a_sync.a_sync.function.ASyncFunction`.
9
+
10
+ See Also:
11
+ - :class:`~a_sync.a_sync.function.ASyncFunction`
12
+ - :class:`~a_sync.a_sync.method.ASyncMethodDescriptor`
13
+ - :class:`~a_sync.a_sync.property.ASyncPropertyDescriptor`
14
+ """
15
+
16
+ import asyncio
17
+
18
+ from a_sync._typing import *
19
+ from a_sync.a_sync import decorator
20
+ from a_sync.a_sync.function import ASyncFunction
21
+ from a_sync.a_sync.function cimport _ASyncFunction, _ModifiedMixin, _validate_wrapped_fn
22
+ from a_sync.a_sync.modifiers.manager cimport ModifierManager
23
+ from a_sync.functools cimport cached_property_unsafe, update_wrapper
24
+
25
+ if TYPE_CHECKING:
26
+ from a_sync import TaskMapping
27
+
28
+ else:
29
+ # due to circ import issues we will populate this later
30
+ TaskMapping = None
31
+
32
+
33
+ # cdef asyncio
34
+ cdef object iscoroutinefunction = asyncio.iscoroutinefunction
35
+ del asyncio
36
+
37
+ cdef object a_sync = decorator.a_sync
38
+
39
+
40
+ cdef class _ASyncDescriptor(_ModifiedMixin):
41
+ """
42
+ A descriptor base class for dual-function ASync methods and properties.
43
+
44
+ This class provides functionality for mapping operations across multiple instances
45
+ and includes utility methods for common operations such as checking if all or any
46
+ results are truthy, and finding the minimum, maximum, or sum of results of the method
47
+ or property mapped across multiple instances through the use of :class:`~a_sync.a_sync.function.ASyncFunction`.
48
+
49
+ Examples:
50
+ To create a dual-function method or property, subclass :class:`ASyncDescriptor` and implement
51
+ the desired functionality. You can then use the provided utility methods to perform operations
52
+ across multiple instances.
53
+
54
+ ```python
55
+ class MyClass:
56
+ @ASyncDescriptor
57
+ def my_method(self, x):
58
+ return x * 2
59
+
60
+ instance = MyClass()
61
+ result = instance.my_method.map([1, 2, 3])
62
+ ```
63
+
64
+ See Also:
65
+ - :class:`~a_sync.a_sync.function.ASyncFunction`
66
+ - :class:`~a_sync.a_sync.method.ASyncMethodDescriptor`
67
+ """
68
+ cdef readonly str field_name
69
+ cdef readonly object _fget
70
+
71
+ def __init__(
72
+ self,
73
+ _fget: AnyFn[Concatenate[I, P], T],
74
+ field_name: Optional[str] = None,
75
+ **modifiers: ModifierKwargs,
76
+ ) -> None:
77
+ """
78
+ Initialize the :class:`ASyncDescriptor`.
79
+
80
+ Args:
81
+ _fget: The function to be wrapped.
82
+ field_name: Optional name for the field. If not provided, the function's name will be used.
83
+ **modifiers: Additional modifier arguments.
84
+
85
+ Raises:
86
+ ValueError: If _fget is not callable.
87
+ """
88
+ if not callable(_fget):
89
+ raise ValueError(f"Unable to decorate {_fget}")
90
+ self.modifiers = ModifierManager(modifiers)
91
+ if isinstance(_fget, _ASyncFunction):
92
+ self.modifiers._modifiers.update((<_ModifiedMixin>_fget).modifiers._modifiers)
93
+
94
+ self.__wrapped__ = _fget
95
+ elif iscoroutinefunction(_fget):
96
+ _validate_wrapped_fn(_fget)
97
+ self.__wrapped__ = self.modifiers.apply_async_modifiers(
98
+ _fget
99
+ )
100
+ else:
101
+ _validate_wrapped_fn(_fget)
102
+ self.__wrapped__ = _fget
103
+
104
+ self.field_name = field_name or _fget.__name__
105
+ """The name of the field the :class:`ASyncDescriptor` is bound to."""
106
+
107
+ def __repr__(self) -> str:
108
+ return f"<{self.__class__.__name__} for {self.__wrapped__}>"
109
+
110
+ def __set_name__(self, owner, name):
111
+ """
112
+ Set the field name when the :class:`ASyncDescriptor` is assigned to a class.
113
+
114
+ Args:
115
+ owner: The class owning this descriptor.
116
+ name: The name assigned to this descriptor in the class.
117
+ """
118
+ self.field_name = name
119
+
120
+ def map(
121
+ self, *instances: AnyIterable[I], **bound_method_kwargs: P.kwargs
122
+ ) -> "TaskMapping[I, T]":
123
+ """
124
+ Create a :class:`TaskMapping` for the given instances.
125
+
126
+ Args:
127
+ *instances: Iterable of instances to map over.
128
+ **bound_method_kwargs: Additional keyword arguments for the bound method.
129
+
130
+ Returns:
131
+ A :class:`TaskMapping` object.
132
+
133
+ Examples:
134
+ class MyClass:
135
+ @ASyncDescriptor
136
+ def my_method(self, x):
137
+ return x * 2
138
+
139
+ instance = MyClass()
140
+ result = instance.my_method.map([1, 2, 3])
141
+ """
142
+ if TaskMapping is None:
143
+ _import_TaskMapping()
144
+ return TaskMapping(self, *instances, **bound_method_kwargs)
145
+
146
+ @cached_property_unsafe
147
+ def all(self) -> "ASyncFunction[Concatenate[AnyIterable[I], P], bool]":
148
+ """
149
+ Create an :class:`~ASyncFunction` that checks if all results are truthy.
150
+
151
+ Returns:
152
+ An :class:`ASyncFunction` object.
153
+
154
+ Examples:
155
+ class MyClass:
156
+ @ASyncDescriptor
157
+ def my_method(self, x):
158
+ return x > 0
159
+
160
+ instance = MyClass()
161
+ result = await instance.my_method.all([1, 2, 3])
162
+ """
163
+ return a_sync(default=self.get_default())(self._all)
164
+
165
+ @cached_property_unsafe
166
+ def any(self) -> "ASyncFunction[Concatenate[AnyIterable[I], P], bool]":
167
+ """
168
+ Create an :class:`~ASyncFunction` that checks if any result is truthy.
169
+
170
+ Returns:
171
+ An :class:`ASyncFunction` object.
172
+
173
+ Examples:
174
+ class MyClass:
175
+ @ASyncDescriptor
176
+ def my_method(self, x):
177
+ return x > 0
178
+
179
+ instance = MyClass()
180
+ result = await instance.my_method.any([-1, 0, 1])
181
+ """
182
+ return a_sync(default=self.get_default())(self._any)
183
+
184
+ @cached_property_unsafe
185
+ def min(self) -> "ASyncFunction[Concatenate[AnyIterable[I], P], T]":
186
+ """
187
+ Create an :class:`~ASyncFunction` that returns the minimum result.
188
+
189
+ Returns:
190
+ An :class:`ASyncFunction` object.
191
+
192
+ Examples:
193
+ ```python
194
+ class MyClass:
195
+ @ASyncDescriptor
196
+ def my_method(self, x):
197
+ return x
198
+
199
+ instance = MyClass()
200
+ result = await instance.my_method.min([3, 1, 2])
201
+ ```
202
+ """
203
+ return a_sync(default=self.get_default())(self._min)
204
+
205
+ @cached_property_unsafe
206
+ def max(self) -> "ASyncFunction[Concatenate[AnyIterable[I], P], T]":
207
+ """
208
+ Create an :class:`~ASyncFunction` that returns the maximum result.
209
+
210
+ Returns:
211
+ An :class:`ASyncFunction` object.
212
+
213
+ Examples:
214
+ class MyClass:
215
+ @ASyncDescriptor
216
+ def my_method(self, x):
217
+ return x
218
+
219
+ instance = MyClass()
220
+ result = await instance.my_method.max([3, 1, 2])
221
+ """
222
+ return a_sync(default=self.get_default())(self._max)
223
+
224
+ @cached_property_unsafe
225
+ def sum(self) -> "ASyncFunction[Concatenate[AnyIterable[I], P], T]":
226
+ """
227
+ Create an :class:`~ASyncFunction` that returns the sum of results.
228
+
229
+ Returns:
230
+ An :class:`ASyncFunction` object.
231
+
232
+ Examples:
233
+ ```python
234
+ class MyClass:
235
+ @ASyncDescriptor
236
+ def my_method(self, x):
237
+ return x
238
+
239
+ instance = MyClass()
240
+ result = await instance.my_method.sum([1, 2, 3])
241
+ ```
242
+ """
243
+ return a_sync(default=self.get_default())(self._sum)
244
+
245
+ async def _all(
246
+ self,
247
+ *instances: AnyIterable[I],
248
+ concurrency: Optional[int] = None,
249
+ name: str = "",
250
+ **kwargs: P.kwargs,
251
+ ) -> bool:
252
+ """
253
+ Check if all results are truthy.
254
+
255
+ Args:
256
+ *instances: Iterable of instances to check.
257
+ concurrency: Optional maximum number of concurrent tasks.
258
+ name: Optional name for the task.
259
+ **kwargs: Additional keyword arguments.
260
+
261
+ Examples:
262
+ ```python
263
+ class MyClass:
264
+ @ASyncDescriptor
265
+ def my_method(self, x):
266
+ return x > 0
267
+
268
+ instance = MyClass()
269
+ result = await instance.my_method._all([1, 2, 3])
270
+ ```
271
+ """
272
+ return await self.map(*instances, concurrency=concurrency, name=name, **kwargs).all(
273
+ pop=True, sync=False
274
+ )
275
+
276
+ async def _any(
277
+ self,
278
+ *instances: AnyIterable[I],
279
+ concurrency: Optional[int] = None,
280
+ name: str = "",
281
+ **kwargs: P.kwargs,
282
+ ) -> bool:
283
+ """
284
+ Check if any result is truthy.
285
+
286
+ Args:
287
+ *instances: Iterable of instances to check.
288
+ concurrency: Optional maximum number of concurrent tasks.
289
+ name: Optional name for the task.
290
+ **kwargs: Additional keyword arguments.
291
+
292
+ Examples:
293
+ ```python
294
+ class MyClass:
295
+ @ASyncDescriptor
296
+ def my_method(self, x):
297
+ return x > 0
298
+
299
+ instance = MyClass()
300
+ result = await instance.my_method._any([-1, 0, 1])
301
+ ```
302
+ """
303
+ return await self.map(*instances, concurrency=concurrency, name=name, **kwargs).any(
304
+ pop=True, sync=False
305
+ )
306
+
307
+ async def _min(
308
+ self,
309
+ *instances: AnyIterable[I],
310
+ concurrency: Optional[int] = None,
311
+ name: str = "",
312
+ **kwargs: P.kwargs,
313
+ ) -> T:
314
+ """
315
+ Find the minimum result.
316
+
317
+ Args:
318
+ *instances: Iterable of instances to check.
319
+ concurrency: Optional maximum number of concurrent tasks.
320
+ name: Optional name for the task.
321
+ **kwargs: Additional keyword arguments.
322
+
323
+ Examples:
324
+ ```python
325
+ class MyClass:
326
+ @ASyncDescriptor
327
+ def my_method(self, x):
328
+ return x
329
+
330
+ instance = MyClass()
331
+ result = await instance.my_method._min([3, 1, 2])
332
+ ```
333
+ """
334
+ return await self.map(*instances, concurrency=concurrency, name=name, **kwargs).min(
335
+ pop=True, sync=False
336
+ )
337
+
338
+ async def _max(
339
+ self,
340
+ *instances: AnyIterable[I],
341
+ concurrency: Optional[int] = None,
342
+ name: str = "",
343
+ **kwargs: P.kwargs,
344
+ ) -> T:
345
+ """
346
+ Find the maximum result.
347
+
348
+ Args:
349
+ *instances: Iterable of instances to check.
350
+ concurrency: Optional maximum number of concurrent tasks.
351
+ name: Optional name for the task.
352
+ **kwargs: Additional keyword arguments.
353
+
354
+ Examples:
355
+ ```python
356
+ class MyClass:
357
+ @ASyncDescriptor
358
+ def my_method(self, x):
359
+ return x
360
+
361
+ instance = MyClass()
362
+ result = await instance.my_method._max([3, 1, 2])
363
+ ```
364
+ """
365
+ return await self.map(*instances, concurrency=concurrency, name=name, **kwargs).max(
366
+ pop=True, sync=False
367
+ )
368
+
369
+ async def _sum(
370
+ self,
371
+ *instances: AnyIterable[I],
372
+ concurrency: Optional[int] = None,
373
+ name: str = "",
374
+ **kwargs: P.kwargs,
375
+ ) -> T:
376
+ """
377
+ Calculate the sum of results.
378
+
379
+ Args:
380
+ *instances: Iterable of instances to sum.
381
+ concurrency: Optional maximum number of concurrent tasks.
382
+ name: Optional name for the task.
383
+ **kwargs: Additional keyword arguments.
384
+
385
+ Examples:
386
+ ```python
387
+ class MyClass:
388
+ @ASyncDescriptor
389
+ def my_method(self, x):
390
+ return x
391
+
392
+ instance = MyClass()
393
+ result = await instance.my_method._sum([1, 2, 3])
394
+ ```
395
+ """
396
+ return await self.map(*instances, concurrency=concurrency, name=name, **kwargs).sum(
397
+ pop=True, sync=False
398
+ )
399
+
400
+
401
+ # these resolve a conflict between cdef class and @cached_property
402
+ _ASyncDescriptor.any.__set_name__(_ASyncDescriptor, "any")
403
+ _ASyncDescriptor.all.__set_name__(_ASyncDescriptor, "all")
404
+ _ASyncDescriptor.min.__set_name__(_ASyncDescriptor, "min")
405
+ _ASyncDescriptor.max.__set_name__(_ASyncDescriptor, "max")
406
+ _ASyncDescriptor.sum.__set_name__(_ASyncDescriptor, "sum")
407
+
408
+
409
+ class ASyncDescriptor(_ASyncDescriptor, Generic[I, P, T]):
410
+ def __init__(self, _fget: AnyFn[Concatenate[I, P], T], field_name: Optional[str] = None, **modifiers: ModifierKwargs) -> None:
411
+ super().__init__(_fget, field_name, **modifiers)
412
+ update_wrapper(self, self.__wrapped__)
413
+ def __init_subclass__(cls) -> None:
414
+ for attr in cls.__dict__.values():
415
+ if attr.__doc__ and "{cls}" in attr.__doc__:
416
+ attr.__doc__ = attr.__doc__.replace("{cls}", f":class:`{cls.__name__}`")
417
+ return super().__init_subclass__()
418
+
419
+
420
+ cdef inline void _import_TaskMapping():
421
+ global TaskMapping
422
+ from a_sync import TaskMapping