python-iterutils 0.2.5.3__py3-none-any.whl → 0.2.5.5__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.
iterutils/__init__.py CHANGED
@@ -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 isawaitable(ret):
181
- value: Any = await ret
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 threaded or isinstance(iterable, AsyncIterable) or any(isinstance(i, AsyncIterable) for i in iterables):
484
- return async_zip(iterable, *iterables, threaded=threaded)
485
- return _zip(iterable, *iterables)
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 or not isinstance(iterable, Iterable):
511
- return async_chain(iterable, *iterables, threaded=threaded)
512
- return _chain(iterable, *iterables) # type: ignore
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 threaded or not (isinstance(iterable, Iterable) and all(isinstance(it, Iterable) for it in iterables)):
593
- return async_foreach(value, iterable, *iterables, threaded=threaded)
594
- if iterables:
595
- for args in _zip(iterable, *iterables):
596
- value(*args)
597
- else:
598
- for arg in iterable:
599
- value(arg)
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(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-iterutils
3
- Version: 0.2.5.3
3
+ Version: 0.2.5.5
4
4
  Summary: Python another itertools.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-iterutils
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
2
+ iterutils/__init__.py,sha256=kl1R5zSu8uLPSyd0Yvv8IVKjx4iA0WWGiS2ioKua7yc,33830
3
+ iterutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ python_iterutils-0.2.5.5.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
5
+ python_iterutils-0.2.5.5.dist-info/METADATA,sha256=_L5FWThA3XcChxhSiv6to6okvzm3SUC0fJQPuU3G2vw,1429
6
+ python_iterutils-0.2.5.5.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
7
+ python_iterutils-0.2.5.5.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
2
- iterutils/__init__.py,sha256=EVELTMkPih-vJsPKQNA21GJz_NlDIDLrZyhOA4muVTQ,33593
3
- iterutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- python_iterutils-0.2.5.3.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
5
- python_iterutils-0.2.5.3.dist-info/METADATA,sha256=ZE7kllJMWnKNk0hHV_2i26nhrrphLPccEeaAPhJ1Dyo,1429
6
- python_iterutils-0.2.5.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
7
- python_iterutils-0.2.5.3.dist-info/RECORD,,