From b4b843ff79f863216e71ee169ca735267fddc27b Mon Sep 17 00:00:00 2001 From: zhang-liang-pengkun Date: Fri, 24 Nov 2023 12:21:37 +0800 Subject: [PATCH] more.py: document ilen Signed-off-by: zhang-liang-pengkun --- 0002-more.py-document-ilen.patch | 29 +++++++++++++++++++++++++++++ python-more-itertools.spec | 4 ++++ 2 files changed, 33 insertions(+) create mode 100644 0002-more.py-document-ilen.patch diff --git a/0002-more.py-document-ilen.patch b/0002-more.py-document-ilen.patch new file mode 100644 index 0000000..24214e0 --- /dev/null +++ b/0002-more.py-document-ilen.patch @@ -0,0 +1,29 @@ +From fc39d84358199cd0fc7a33e9179244a4987e36c7 Mon Sep 17 00:00:00 2001 +From: Ben Mintz +Date: Mon, 7 May 2018 03:29:41 -0500 +Subject: [PATCH] more.py: document ilen + +I found the implementation of ilen to be confusing, so I documented it. +--- + more_itertools/more.py | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/more_itertools/more.py b/more_itertools/more.py +index 6de5b03..a5fd960 100644 +--- a/more_itertools/more.py ++++ b/more_itertools/more.py +@@ -409,7 +409,11 @@ def ilen(iterable): + This consumes the iterable, so handle with care. + + """ ++ # maxlen=1 only stores the last item in the deque + d = deque(enumerate(iterable, 1), maxlen=1) ++ # since we started enumerate at 1, ++ # the first item of the last pair will be the length of the iterable ++ # (assuming there were items) + return d[0][0] if d else 0 + + +-- +2.39.0.windows.2 + diff --git a/python-more-itertools.spec b/python-more-itertools.spec index 4accc9d..76ab9db 100644 --- a/python-more-itertools.spec +++ b/python-more-itertools.spec @@ -8,6 +8,7 @@ Source0: https://pypi.io/packages/source/m/more-itertools/more-itertools- BuildArch: noarch Patch0000: python37.patch Patch0001: 0001-fix-for-python-3.7-deprecation-warning-about-importi.patch +Patch0002: 0002-more.py-document-ilen.patch %description This is a python library for efficient use of itertools utility, which also \ @@ -62,6 +63,9 @@ See https://pythonhosted.org/more-itertools/index.html for more information. %{python3_sitelib}/more_itertools-%{version}-py%{python3_version}.egg-info %changelog +* Fri Nov 24 2023 zhangliangpengkun - +- more.py: document ilen + * Thu Nov 16 2023 zhangliangpengkun - 4.1.0-6 - fix for python 3.7 deprecation warning about importing certain types from collections vs collections.abc