On 01.10.12 22:54, philip.jenvey wrote:
http://hg.python.org/cpython/rev/fb90e2ff95b7
changeset:   79378:fb90e2ff95b7
user:        Philip Jenvey <pjen...@underboss.org>
date:        Mon Oct 01 12:53:43 2012 -0700
summary:
   utilize yield from

This is not all.

diff -r fb90e2ff95b7 Lib/http/cookiejar.py
--- a/Lib/http/cookiejar.py	Mon Oct 01 12:53:43 2012 -0700
+++ b/Lib/http/cookiejar.py	Tue Oct 02 00:28:41 2012 +0300
@@ -1193,8 +1193,7 @@
             pass
         else:
             mapping = True
-            for subobj in deepvalues(obj):
-                yield subobj
+            yield from deepvalues(obj)
         if not mapping:
             yield obj
 
diff -r fb90e2ff95b7 Lib/json/encoder.py
--- a/Lib/json/encoder.py	Mon Oct 01 12:53:43 2012 -0700
+++ b/Lib/json/encoder.py	Tue Oct 02 00:28:41 2012 +0300
@@ -305,8 +305,7 @@
                     chunks = _iterencode_dict(value, _current_indent_level)
                 else:
                     chunks = _iterencode(value, _current_indent_level)
-                for chunk in chunks:
-                    yield chunk
+                yield from chunks
         if newline_indent is not None:
             _current_indent_level -= 1
             yield '\n' + _indent * _current_indent_level
@@ -381,8 +380,7 @@
                     chunks = _iterencode_dict(value, _current_indent_level)
                 else:
                     chunks = _iterencode(value, _current_indent_level)
-                for chunk in chunks:
-                    yield chunk
+                yield from chunks
         if newline_indent is not None:
             _current_indent_level -= 1
             yield '\n' + _indent * _current_indent_level
@@ -404,11 +402,9 @@
         elif isinstance(o, float):
             yield _floatstr(o)
         elif isinstance(o, (list, tuple)):
-            for chunk in _iterencode_list(o, _current_indent_level):
-                yield chunk
+            yield from _iterencode_list(o, _current_indent_level)
         elif isinstance(o, dict):
-            for chunk in _iterencode_dict(o, _current_indent_level):
-                yield chunk
+            yield from _iterencode_dict(o, _current_indent_level)
         else:
             if markers is not None:
                 markerid = id(o)
@@ -416,8 +412,7 @@
                     raise ValueError("Circular reference detected")
                 markers[markerid] = o
             o = _default(o)
-            for chunk in _iterencode(o, _current_indent_level):
-                yield chunk
+            yield from _iterencode(o, _current_indent_level)
             if markers is not None:
                 del markers[markerid]
     return _iterencode
diff -r fb90e2ff95b7 Lib/xml/etree/ElementPath.py
--- a/Lib/xml/etree/ElementPath.py	Mon Oct 01 12:53:43 2012 -0700
+++ b/Lib/xml/etree/ElementPath.py	Tue Oct 02 00:28:41 2012 +0300
@@ -105,14 +105,12 @@
 def prepare_star(next, token):
     def select(context, result):
         for elem in result:
-            for e in elem:
-                yield e
+            yield from elem
     return select
 
 def prepare_self(next, token):
     def select(context, result):
-        for elem in result:
-            yield elem
+        yield from result
     return select
 
 def prepare_descendant(next, token):
diff -r fb90e2ff95b7 Lib/xml/etree/ElementTree.py
--- a/Lib/xml/etree/ElementTree.py	Mon Oct 01 12:53:43 2012 -0700
+++ b/Lib/xml/etree/ElementTree.py	Tue Oct 02 00:28:41 2012 +0300
@@ -459,8 +459,7 @@
         if tag is None or self.tag == tag:
             yield self
         for e in self._children:
-            for e in e.iter(tag):
-                yield e
+            yield from e.iter(tag)
 
     # compatibility
     def getiterator(self, tag=None):
@@ -487,8 +486,7 @@
         if self.text:
             yield self.text
         for e in self:
-            for s in e.itertext():
-                yield s
+            yield from e.itertext()
             if e.tail:
                 yield e.tail
 
diff -r fb90e2ff95b7 Tools/importbench/importbench.py
--- a/Tools/importbench/importbench.py	Mon Oct 01 12:53:43 2012 -0700
+++ b/Tools/importbench/importbench.py	Tue Oct 02 00:28:41 2012 +0300
@@ -46,8 +46,7 @@
     module.__package__ = ''
     with util.uncache(name):
         sys.modules[name] = module
-        for result in bench(name, repeat=repeat, seconds=seconds):
-            yield result
+        yield from bench(name, repeat=repeat, seconds=seconds)
 
 
 def builtin_mod(seconds, repeat):
@@ -56,9 +55,8 @@
     if name in sys.modules:
         del sys.modules[name]
     # Relying on built-in importer being implicit.
-    for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
-                        seconds=seconds):
-        yield result
+    yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+                     seconds=seconds)
 
 
 def source_wo_bytecode(seconds, repeat):
@@ -73,9 +71,8 @@
             loader = (importlib.machinery.SourceFileLoader,
                       importlib.machinery.SOURCE_SUFFIXES, True)
             sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader))
-            for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
-                                seconds=seconds):
-                yield result
+            yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+                             seconds=seconds)
     finally:
         sys.dont_write_bytecode = False
 
@@ -89,9 +86,8 @@
             os.unlink(bytecode_path)
         sys.dont_write_bytecode = True
         try:
-            for result in bench(name, lambda: sys.modules.pop(name),
-                                repeat=repeat, seconds=seconds):
-                yield result
+            yield from bench(name, lambda: sys.modules.pop(name),
+                             repeat=repeat, seconds=seconds)
         finally:
             sys.dont_write_bytecode = False
 
@@ -127,8 +123,7 @@
         def cleanup():
             sys.modules.pop(name)
             os.unlink(imp.cache_from_source(module.__file__))
-        for result in bench(name, cleanup, repeat=repeat, seconds=seconds):
-            yield result
+        yield from bench(name, cleanup, repeat=repeat, seconds=seconds)
 
     writing_bytecode_benchmark.__doc__ = (
                                 writing_bytecode_benchmark.__doc__.format(name))
@@ -148,9 +143,8 @@
         sys.path_hooks.append(importlib.machinery.FileFinder.path_hook(loader))
         py_compile.compile(mapping[name])
         assert os.path.exists(imp.cache_from_source(mapping[name]))
-        for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
-                            seconds=seconds):
-            yield result
+        yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+                         seconds=seconds)
 
 
 def _using_bytecode(module):
@@ -158,9 +152,8 @@
     def using_bytecode_benchmark(seconds, repeat):
         """Source w/ bytecode: {}"""
         py_compile.compile(module.__file__)
-        for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
-                            seconds=seconds):
-            yield result
+        yield from bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+                         seconds=seconds)
 
     using_bytecode_benchmark.__doc__ = (
                                 using_bytecode_benchmark.__doc__.format(name))
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to