python-iterutils 0.2.5.3__tar.gz → 0.2.5.5__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.
- {python_iterutils-0.2.5.3 → python_iterutils-0.2.5.5}/PKG-INFO +1 -1
- {python_iterutils-0.2.5.3 → python_iterutils-0.2.5.5}/iterutils/__init__.py +29 -18
- {python_iterutils-0.2.5.3 → python_iterutils-0.2.5.5}/pyproject.toml +1 -1
- {python_iterutils-0.2.5.3 → python_iterutils-0.2.5.5}/LICENSE +0 -0
- {python_iterutils-0.2.5.3 → python_iterutils-0.2.5.5}/iterutils/py.typed +0 -0
- {python_iterutils-0.2.5.3 → python_iterutils-0.2.5.5}/readme.md +0 -0
|
@@ -177,10 +177,8 @@ async def _run_gen_step_async_iter(gen: Generator, /) -> AsyncIterator:
|
|
|
177
177
|
ret: Any = send(None)
|
|
178
178
|
while True:
|
|
179
179
|
try:
|
|
180
|
-
if
|
|
181
|
-
value: Any =
|
|
182
|
-
else:
|
|
183
|
-
value = ret.value
|
|
180
|
+
if isinstance(ret, (Yield, YieldFrom)):
|
|
181
|
+
value: Any = ret.value
|
|
184
182
|
if isawaitable(value):
|
|
185
183
|
value = await value
|
|
186
184
|
if isinstance(ret, Yield):
|
|
@@ -191,6 +189,10 @@ async def _run_gen_step_async_iter(gen: Generator, /) -> AsyncIterator:
|
|
|
191
189
|
else:
|
|
192
190
|
for e in value:
|
|
193
191
|
yield e
|
|
192
|
+
elif isawaitable(ret):
|
|
193
|
+
value = await ret
|
|
194
|
+
else:
|
|
195
|
+
value = ret
|
|
194
196
|
except BaseException as e:
|
|
195
197
|
ret = throw(e)
|
|
196
198
|
else:
|
|
@@ -480,9 +482,12 @@ def zip(
|
|
|
480
482
|
):
|
|
481
483
|
"""
|
|
482
484
|
"""
|
|
483
|
-
if
|
|
484
|
-
|
|
485
|
-
|
|
485
|
+
if (not threaded and
|
|
486
|
+
isinstance(iterable, Iterable) and
|
|
487
|
+
all(isinstance(it, Iterable) for it in iterables)
|
|
488
|
+
):
|
|
489
|
+
return _zip(iterable, *iterables)
|
|
490
|
+
return async_zip(iterable, *iterables, threaded=threaded)
|
|
486
491
|
|
|
487
492
|
|
|
488
493
|
@overload
|
|
@@ -507,9 +512,12 @@ def chain[T](
|
|
|
507
512
|
*iterables: Iterable[T] | AsyncIterable[T],
|
|
508
513
|
threaded: bool = False,
|
|
509
514
|
) -> Iterator[T] | AsyncIterator[T]:
|
|
510
|
-
if threaded
|
|
511
|
-
|
|
512
|
-
|
|
515
|
+
if (not threaded and
|
|
516
|
+
isinstance(iterable, Iterable) and
|
|
517
|
+
all(isinstance(it, Iterable) for it in iterables)
|
|
518
|
+
):
|
|
519
|
+
return _chain(iterable, *iterables) # type: ignore
|
|
520
|
+
return async_chain(iterable, *iterables, threaded=threaded)
|
|
513
521
|
|
|
514
522
|
|
|
515
523
|
@overload
|
|
@@ -589,14 +597,17 @@ def foreach(
|
|
|
589
597
|
):
|
|
590
598
|
"""
|
|
591
599
|
"""
|
|
592
|
-
if
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
+
if (not threaded and
|
|
601
|
+
isinstance(iterable, Iterable) and
|
|
602
|
+
all(isinstance(it, Iterable) for it in iterables)
|
|
603
|
+
):
|
|
604
|
+
if iterables:
|
|
605
|
+
for args in _zip(iterable, *iterables):
|
|
606
|
+
value(*args)
|
|
607
|
+
else:
|
|
608
|
+
for arg in iterable:
|
|
609
|
+
value(arg)
|
|
610
|
+
return async_foreach(value, iterable, *iterables, threaded=threaded)
|
|
600
611
|
|
|
601
612
|
|
|
602
613
|
async def async_foreach(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|