diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2008-03-07 14:13:28 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2008-03-07 14:13:28 (GMT) |
commit | 7af53be66f8c074902e0e7e7c452a280538582bc (patch) | |
tree | c2d5933745c44a5099ceadb4f81bc7aa82dfe1c1 /Lib/compiler/pycodegen.py | |
parent | e75f59a578a4538451c1d96610a6d183ba8f2e81 (diff) | |
download | cpython-7af53be66f8c074902e0e7e7c452a280538582bc.zip cpython-7af53be66f8c074902e0e7e7c452a280538582bc.tar.gz cpython-7af53be66f8c074902e0e7e7c452a280538582bc.tar.bz2 |
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)
Diffstat (limited to 'Lib/compiler/pycodegen.py')
-rw-r--r-- | Lib/compiler/pycodegen.py | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py index b46b1c1..5d227b8 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() |