From 7af53be66f8c074902e0e7e7c452a280538582bc Mon Sep 17 00:00:00 2001 From: Nick Coghlan Date: Fri, 7 Mar 2008 14:13:28 +0000 Subject: Speed up with statements by storing the __exit__ method on the stack instead of in a temp variable (bumps the magic number for pyc files) --- Lib/compiler/pycodegen.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'Lib/compiler/pycodegen.py') diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index b46b1c1489..5d227b87fe 100644 --- a/Lib/compiler/pycodegen.py +++ b/Lib/compiler/pycodegen.py @@ -822,14 +822,13 @@ class CodeGenerator: def visitWith(self, node): body = self.newBlock() final = self.newBlock() - exitvar = "$exit%d" % self.__with_count valuevar = "$value%d" % self.__with_count self.__with_count += 1 self.set_lineno(node) self.visit(node.expr) self.emit('DUP_TOP') self.emit('LOAD_ATTR', '__exit__') - self._implicitNameOp('STORE', exitvar) + self.emit('ROT_TWO') self.emit('LOAD_ATTR', '__enter__') self.emit('CALL_FUNCTION', 0) if node.vars is None: @@ -849,8 +848,6 @@ class CodeGenerator: self.emit('LOAD_CONST', None) self.nextBlock(final) self.setups.push((END_FINALLY, final)) - self._implicitNameOp('LOAD', exitvar) - self._implicitNameOp('DELETE', exitvar) self.emit('WITH_CLEANUP') self.emit('END_FINALLY') self.setups.pop() -- cgit v1.2.1