[Python-Dev] dis module and new-style classes
Guido van Rossum
guido at python.org
Thu Apr 6 22:36:37 CEST 2006
Sorry, I missed the fact that this was about nested classes.
Still, I don't think it's worth fixing.
--Guido
On 4/6/06, Georg Brandl <g.brandl at gmx.net> wrote:
> Guido van Rossum wrote:
> > I think it's fine as it is. I don't think making it walk the
> > inheritance tree is helpful; the output would be too large. Also, an
> > instance doesn't have any code and that's fine too.
>
> Inheritance has nothing to do with that.
>
> > (Didn't you mean "dis.dis(D) doesn't touch C"?)
>
> No.
>
> > On 4/6/06, Georg Brandl <g.brandl at gmx.net> wrote:
> >> Hi,
> >>
> >> dis.dis currently handles new-style classes stepmotherly: given
> >>
> >> class C(object):
> >> def Cm(): pass
> >> class D(object):
> >> def Dm(): pass
> >>
> >> dis.dis(C) doesn't touch D, and
> >> dis.dis(C()) doesn't touch anything.
> >>
> >> Should it be fixed? It may need some reworking in dis.dis.
>
> Here is an example transcript to make clearer what I mean:
>
> Python 2.4.2 (#1, Mar 12 2006, 00:14:41)
> >>> import dis
> >>> class C:
> ... def Cm(): pass
> ... class D:
> ... def Dm(): pass
> ...
> >>> dis.dis(C)
> Disassembly of Cm:
> 2 0 LOAD_CONST 0 (None)
> 3 RETURN_VALUE
>
> Disassembly of D:
> Disassembly of Dm:
> 4 0 LOAD_CONST 0 (None)
> 3 RETURN_VALUE
>
>
> >>> dis.dis(C())
> Disassembly of Cm:
> 2 0 LOAD_CONST 0 (None)
> 3 RETURN_VALUE
>
> Disassembly of D:
> Disassembly of Dm:
> 4 0 LOAD_CONST 0 (None)
> 3 RETURN_VALUE
>
>
> >>> class Co(object):
> ... def Cm(): pass
> ... class Do(object):
> ... def Dm(): pass
> ...
> >>> dis.dis(Co)
> Disassembly of Cm:
> 2 0 LOAD_CONST 0 (None)
> 3 RETURN_VALUE
>
> >>> dis.dis(Co())
> >>>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list