[Python-Dev] Simplify lnotab? (AST branch update)

Phillip J. Eby pje at telecommunity.com
Fri Oct 14 17:20:45 CEST 2005

At 08:07 PM 10/14/2005 +1300, Greg Ewing wrote:
>Phillip J. Eby wrote:
> > A more
> > compact scheme is possible, by using two tables - a bytecode->line
> > number table, and a line number-> file table.
> >
> > If you have to encode multiple files, you just offset their line numbers
> > by the size of the other files,
>More straightforwardly, the second table could just be a
>bytecode -> file number mapping.

That would use more space in any case involving multiple files.

>In the case of only one file, it would contain just a single
>entry, so it probably wouldn't even be worth the bother of
>special-casing that.

A line->file mapping would also have only one entry in that case.

>You could save a bit more by having two kinds of line number
>table, "small" (16-bit entries) and "large" (32-bit entries)
>depending on the size of the code object and range of line
>numbers. The small one would be sufficient for almost all
>code objects, so the most common case would use only about
>4 bytes per line of code. That's only twice as much as the
>current scheme uses.

That'd probably work.

More information about the Python-Dev mailing list