Commits

Robert Kern  committed 0b555e6

BUG: the label() function actually goes in the Cython file.

  • Participants
  • Parent commits 2ea515d

Comments (0)

Files changed (2)

File _line_profiler.pyx

 from python25 cimport PyFrameObject, PyObject, PyStringObject
 
-from cProfile import label
 
 cdef extern from "frameobject.h":
     ctypedef int (*Py_tracefunc)(object self, PyFrameObject *py_frame, int what, object arg)
     double hpTimerUnit()
 
 
+def label(code):
+    """ Return a (filename, first_lineno, func_name) tuple for a given code
+    object.
+
+    This is the same labelling as used by the cProfile module in Python 2.5.
+    """
+    if isinstance(code, str):
+        return ('~', 0, code)    # built-in functions ('~' sorts at the end)
+    else:
+        return (code.co_filename, code.co_firstlineno, code.co_name)
+
+
 cdef class LineTiming:
     """ The timing for a single line.
     """

File line_profiler.py

 from _line_profiler import LineProfiler as CLineProfiler
 
 
-def label(code):
-    """ Return a (filename, first_lineno, func_name) tuple for a given code
-    object.
-
-    This is the same labelling as used by the cProfile module in Python 2.5.
-    """
-    if isinstance(code, str):
-        return ('~', 0, code)    # built-in functions ('~' sorts at the end)
-    else:
-        return (code.co_filename, code.co_firstlineno, code.co_name)
-
 class LineProfiler(CLineProfiler):
     """ A profiler that records the execution times of individual lines.
     """