Module/package hierarchy and its separation from file structure

NickC ncoghlan at gmail.com
Mon Feb 4 17:46:13 EST 2008


On Jan 31, 12:27 am, Gabriel Genellina <gagsl-... at yahoo.com.ar> wrote:
> Python stores filename and line number information in code objects
> (only). If you have a reference to any code object (a method, a
> function, a traceback...) inspect can use it to retrieve that
> information.

Aside from general concerns about increasing the size of class objects
(and most programs don't contain enough of those to make a big
difference) I don't immediately see anything that would prevent the
interpreter being modified to add file and line number information to
class objects as well. While the information wouldn't always be
present (types implemented in C, types created by calling the
metaclass constructor directly), it would help address the inspect
module bugs Steven illustrated.

I would agree with Carl that modifying __module__ in the way he
suggests is legitimate - if it breaks the inspect module, then it is
the inspect module that needs fixing (and/or better support from the
interpreter to help find the real source code).

Cheers,
Nick.



More information about the Python-list mailing list