aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/fonttools/fontTools/misc/iterTools.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-06-08 08:51:43 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-06-08 09:02:27 +0300
commitc3763910c6f878b17102c94e0b62cab57c9954b8 (patch)
tree19de35706beeb1adc158f13ca87110e110f1a753 /contrib/python/fonttools/fontTools/misc/iterTools.py
parent63965219325c32d9b72b466b89fc613295746336 (diff)
downloadydb-c3763910c6f878b17102c94e0b62cab57c9954b8.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/fonttools/fontTools/misc/iterTools.py')
-rw-r--r--contrib/python/fonttools/fontTools/misc/iterTools.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/python/fonttools/fontTools/misc/iterTools.py b/contrib/python/fonttools/fontTools/misc/iterTools.py
new file mode 100644
index 0000000000..d7b8305322
--- /dev/null
+++ b/contrib/python/fonttools/fontTools/misc/iterTools.py
@@ -0,0 +1,12 @@
+from itertools import *
+
+# Python 3.12:
+if "batched" not in globals():
+ # https://docs.python.org/3/library/itertools.html#itertools.batched
+ def batched(iterable, n):
+ # batched('ABCDEFG', 3) --> ABC DEF G
+ if n < 1:
+ raise ValueError("n must be at least one")
+ it = iter(iterable)
+ while batch := tuple(islice(it, n)):
+ yield batch