[pypy-commit] pypy logging-perf: Mark this as immutable.

alex_gaynor noreply at buildbot.pypy.org
Wed May 22 02:25:40 CEST 2013


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: logging-perf
Changeset: r64411:d95d58323a97
Date: 2013-05-21 17:23 -0700
http://bitbucket.org/pypy/pypy/changeset/d95d58323a97/

Log:	Mark this as immutable.

diff --git a/rpython/tool/error.py b/rpython/tool/error.py
--- a/rpython/tool/error.py
+++ b/rpython/tool/error.py
@@ -2,11 +2,15 @@
 """ error handling features, just a way of displaying errors
 """
 
-from rpython.tool.ansi_print import ansi_log
-from rpython.flowspace.model import Variable
 import sys
 
 import py
+
+from rpython.flowspace.model import Variable
+from rpython.rlib import jit
+from rpython.tool.ansi_print import ansi_log
+
+
 log = py.log.Producer("error")
 py.log.setconsumer("error", ansi_log)
 
@@ -14,7 +18,8 @@
 SHOW_ANNOTATIONS = True
 SHOW_DEFAULT_LINES_OF_CODE = 0
 
-def source_lines1(graph, block, operindex=None, offset=None, long=False, \
+
+def source_lines1(graph, block, operindex=None, offset=None, long=False,
     show_lines_of_code=SHOW_DEFAULT_LINES_OF_CODE):
     if block is not None:
         if block is graph.returnblock:
@@ -32,23 +37,24 @@
         else:
             if block is None or not block.operations:
                 return []
+
             def toline(operindex):
                 return offset2lineno(graph.func.func_code, block.operations[operindex].offset)
             if operindex is None:
-                linerange =  (toline(0), toline(-1))
+                linerange = (toline(0), toline(-1))
                 if not long:
                     return ['?']
                 here = None
             else:
                 operline = toline(operindex)
                 if long:
-                    linerange =  (toline(0), toline(-1))
+                    linerange = (toline(0), toline(-1))
                     here = operline
                 else:
                     linerange = (operline, operline)
                     here = None
         lines = ["Happened at file %s line %d" % (graph.filename, here or linerange[0]), ""]
-        for n in range(max(0, linerange[0]-show_lines_of_code), \
+        for n in range(max(0, linerange[0]-show_lines_of_code),
             min(linerange[1]+1+show_lines_of_code, len(graph_lines)+graph.startline)):
             if n == here:
                 prefix = '==> '
@@ -136,6 +142,7 @@
     from rpython.translator.tool.pdbplus import PdbPlusShow
     from rpython.translator.driver import log
     t = drv.translator
+
     class options:
         huge = 100
 
@@ -161,6 +168,7 @@
         pdb_plus_show.start(tb)
 
 
+ at jit.elidable
 def offset2lineno(c, stopat):
     tab = c.co_lnotab
     line = c.co_firstlineno
@@ -170,4 +178,4 @@
         if addr > stopat:
             break
         line = line + ord(tab[i+1])
-    return line
\ No newline at end of file
+    return line


More information about the pypy-commit mailing list