summaryrefslogtreecommitdiffstats
path: root/Lib/compiler
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-10-29 08:53:06 (GMT)
committerGeorg Brandl <georg@python.org>2006-10-29 08:53:06 (GMT)
commit5addf7007818bd05f5a1c26f8c71b5ee839a7659 (patch)
treed481e78083914185ac51d1c8cb9ae048ac9416d5 /Lib/compiler
parent2c4fb8d6012f4ffc534e1ba8c9e50cb139398239 (diff)
downloadcpython-5addf7007818bd05f5a1c26f8c71b5ee839a7659.zip
cpython-5addf7007818bd05f5a1c26f8c71b5ee839a7659.tar.gz
cpython-5addf7007818bd05f5a1c26f8c71b5ee839a7659.tar.bz2
Bug #1586448: the compiler module now emits the same bytecode for
list comprehensions as the builtin compiler, using the LIST_APPEND opcode.
Diffstat (limited to 'Lib/compiler')
-rw-r--r--Lib/compiler/pycodegen.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
index 009438d..0e226fd 100644
--- a/Lib/compiler/pycodegen.py
+++ b/Lib/compiler/pycodegen.py
@@ -573,12 +573,11 @@ class CodeGenerator:
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 @@ class CodeGenerator:
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 @@ class CodeGenerator:
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