Mercurial > cpython-lru_cache-weakref
diff Lib/compiler/pycodegen.py @ 40242:4d833fca3670 legacy-trunk
Bug #1586448: the compiler module now emits the same bytecode for
list comprehensions as the builtin compiler, using the LIST_APPEND
opcode.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 29 Oct 2006 08:53:06 +0000 |
| parents | a6afe0eda711 |
| children | 2a1eae6c0eb8 |
line wrap: on
line diff
--- a/Lib/compiler/pycodegen.py Sun Oct 29 08:47:08 2006 +0000 +++ b/Lib/compiler/pycodegen.py Sun Oct 29 08:53:06 2006 +0000 @@ -573,12 +573,11 @@ def visitListComp(self, node): self.set_lineno(node) # setup list - append = "$append%d" % self.__list_count + tmpname = "$list%d" % self.__list_count self.__list_count = self.__list_count + 1 self.emit('BUILD_LIST', 0) self.emit('DUP_TOP') - self.emit('LOAD_ATTR', 'append') - self._implicitNameOp('STORE', append) + self._implicitNameOp('STORE', tmpname) stack = [] for i, for_ in zip(range(len(node.quals)), node.quals): @@ -590,10 +589,9 @@ self.visit(if_, cont) stack.insert(0, (start, cont, anchor)) - self._implicitNameOp('LOAD', append) + self._implicitNameOp('LOAD', tmpname) self.visit(node.expr) - self.emit('CALL_FUNCTION', 1) - self.emit('POP_TOP') + self.emit('LIST_APPEND',) for start, cont, anchor in stack: if cont: @@ -604,7 +602,7 @@ self.nextBlock(skip_one) self.emit('JUMP_ABSOLUTE', start) self.startBlock(anchor) - self._implicitNameOp('DELETE', append) + self._implicitNameOp('DELETE', tmpname) self.__list_count = self.__list_count - 1
