[Python-Dev] SET_LINENO and python options

Tim Peters tim_one@email.msn.com
Sun, 30 Jul 2000 19:46:12 -0400


[Andrew Kuchling]
> ...
> It always seemed odd to me that the current line number is
> always kept up to date, even though 99.999% of the time, no
> one will care.  Why not just keep a small table that holds
> the offset in the bytecode at which each line starts, and
> look it up when it's needed?

As Guido said, we already do -- indeed, that's how Python manages to produce
line numbers in tracebacks under -O mode (which inhibits generation of
SET_LINENO opcodes).

Your next job <wink> is to think about how, e.g., you can set a breakpoint
on a specific line of code in the debugger.  Take a quick peek at the
implementation of SET_LINENO in ceval.c, and you'll see that's where the
trace hook is implemented.  No SET_LINENO, no trace callback.  That's what
Vladimir has been trying to solve:  the trick is arranging to pay something
at runtime for it only when you're actually using it.

debuggers-always-need-dirty-tricks-ly y'rs  - tim