Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(80)

Unified Diff: Lib/compiler/pyassem.py

Issue 20103: http://bugs.python.org/issue2459 -- speed up loops SVN Base: http://svn.python.org/view/*checkout*/python/trunk/
Patch Set: Created 9 months, 1 week ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side by-side-diff with in-line comments
Download patch
Index: Lib/compiler/pyassem.py
===================================================================
--- Lib/compiler/pyassem.py (revision 70087)
+++ Lib/compiler/pyassem.py (working copy)
@@ -620,6 +620,11 @@
# compute deltas
addr = self.codeOffset - self.lastoff
line = lineno - self.lastline
+ abs_line = abs(line)
+ if line >= 0:
+ sign_line = lambda l: l
+ else:
+ sign_line = lambda l: 256 - l
# Python assumes that lineno always increases with
# increasing bytecode address (lnotab is unsigned char).
# Depending on when SET_LINENO instructions are emitted
@@ -630,19 +635,18 @@
# after the loading of "b". This works with the C Python
# compiler because it only generates a SET_LINENO instruction
# for the assignment.
- if line >= 0:
- push = self.lnotab.append
- while addr > 255:
- push(255); push(0)
- addr -= 255
- while line > 255:
- push(addr); push(255)
- line -= 255
- addr = 0
- if addr > 0 or line > 0:
- push(addr); push(line)
- self.lastline = lineno
- self.lastoff = self.codeOffset
+ push = self.lnotab.append
+ while addr > 255:
+ push(255); push(0)
+ addr -= 255
+ while abs_line > 127:
+ push(addr); push(sign_line(127))
+ abs_line -= 127
+ addr = 0
+ if addr > 0 or abs_line > 0:
+ push(addr); push(sign_line(abs_line))
+ self.lastline = lineno
+ self.lastoff = self.codeOffset
def getCode(self):
return ''.join(self.code)

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497