[Python-Dev] GC, flags, and subtyping

David Abrahams David Abrahams" <david.abrahams@rcn.com
Fri, 5 Apr 2002 00:02:17 -0500


The issue of
http://aspn.activestate.com/ASPN/Mail/Message/python-dev/1041123 is
back.

I had removed Py_TPFLAGS_HAVE_GC from my type, but as Thomas pointed out
in http://aspn.activestate.com/ASPN/Mail/Message/python-dev/1039576, the
flag is set again by PyType_Ready(). That would be fine if the tp_is_gc
field, which is initially zero in my metatype object, were copied
automatically from its base (PyTYpe_Type). As it stands, my metatype is
"forced" to inherit a claim that it handles GC, but the machinery for
determining whether a given instance of the metatype is GC-able is /not/
inherited. Thus, my statically-allocated base instance is treated as
though it was allocated by the GC mechanism.

This seems unneccessarily dangerous to me, and I propose that we change
the semantics of type inheritance to inherit tp_is_gc by default.

Further, I think this points out the need for clarification of the
subtyping mechanism. There should be one place where I can see which
flags and tp_xxx slots are inherited, what they mean, in addition to the
answers to other mysteries hidden in typeobject.c et al. I'm willing to
work something up, if I can get some guidance as to the most appropriate
form. It's not clear to me that there's an appropriate place in the
structure of the API docs
(it's not even clear to me that the API docs are the right place for
this).

-Dave


P.S. One proviso: I find TeX to be cumbersome at best and hair-pullingly
frustrating at worst. If I had to write TeX I probably would just submit
code comprehensibility patches and stop there. I'm probably going to
start with code patches anyway...


+---------------------------------------------------------------+
                  David Abrahams
      C++ Booster (http://www.boost.org)               O__  ==
      Pythonista (http://www.python.org)              c/ /'_ ==
  resume: http://users.rcn.com/abrahams/resume.html  (*) \(*) ==
          email: david.abrahams@rcn.com
+---------------------------------------------------------------+