Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.5
Changeset: r87668:60272f813dd6
Date: 2016-10-09 17:38 +0200
http://bitbucket.org/pypy/pypy/changeset/60272f813dd6/

Log:    Rename operator._length_hint to length_hint.

diff --git a/pypy/module/itertools/test/test_itertools.py 
b/pypy/module/itertools/test/test_itertools.py
--- a/pypy/module/itertools/test/test_itertools.py
+++ b/pypy/module/itertools/test/test_itertools.py
@@ -97,7 +97,7 @@
         raises(TypeError, "len(itertools.repeat('xkcd'))")
 
         r = itertools.repeat('a', -3)
-        assert operator._length_hint(r, 3) == 0
+        assert operator.length_hint(r, 3) == 0
 
     def test_takewhile(self):
         import itertools
diff --git a/pypy/module/operator/__init__.py b/pypy/module/operator/__init__.py
--- a/pypy/module/operator/__init__.py
+++ b/pypy/module/operator/__init__.py
@@ -20,7 +20,7 @@
                     'iadd', 'iand', 'iconcat', 'ifloordiv',
                     'ilshift', 'imod', 'imul', 'ior', 'ipow',
                     'irshift', 'isub', 'itruediv', 'imatmul', 'ixor',
-                    '_length_hint', 'indexOf']
+                    'length_hint', 'indexOf']
 
     interpleveldefs = {
         '_compare_digest': 'tscmp.compare_digest',
diff --git a/pypy/module/operator/interp_operator.py 
b/pypy/module/operator/interp_operator.py
--- a/pypy/module/operator/interp_operator.py
+++ b/pypy/module/operator/interp_operator.py
@@ -209,8 +209,11 @@
 
     return space.inplace_add(w_obj1, w_obj2)
 
-# _length_hint (to be length_hint in 3.4)
-
 @unwrap_spec(default=int)
-def _length_hint(space, w_iterable, default):
+def length_hint(space, w_iterable, default):
+    """Return an estimate of the number of items in obj.
+    This is useful for presizing containers when building from an iterable.
+    If the object supports len(), the result will be exact.
+    Otherwise, it may over- or under-estimate by an arbitrary amount.
+    The result will be an integer >= 0."""
     return space.wrap(space.length_hint(w_iterable, default))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to