[Python-Dev] Re: Class/type dichotomy thoughts

M.-A. Lemburg mal@lemburg.com
Mon, 06 Nov 2000 18:02:51 +0100


Neil Schemenauer wrote:
> 
> On Mon, Nov 06, 2000 at 01:25:26PM +0100, M.-A. Lemburg wrote:
> > I think the problem we currently have with subclassing types
> > is strongly related to the fact that all Py<type>_Check()
> > macros only work on a address compare basis.
> 
> I don't think this is the problem, although it is closely
> related.  The problem is that the interpreter uses these type
> checks to special case the handling of certain types.
> PyInstance_Check() is a big offender.
> 
> Behavior should be based solely on the type structure.  Extension
> types would then be able to behave exactly like any other builtin
> type.  Your coercion proposal and David's rich comparisions both
> remove some of this special casing based on type.

Even though this could remove some of the problems, it doesn't
help much with a common use of Py<Type>_Check(): that of
using fast access macros and native Py<Type>_*() APIs once an
object has been classified as being of a certain type.
This usually improves performance.

By changing the simple address compare to a type handle
system, we might be able to add some more flexibility to
the system while keeping b/w compatibility.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/