On 8/16/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote:
>
> It seems to me that you could drop the FAST_SUBCLASS bit, since none of the
> other bits will be set if it is not a subclass of a builtin.  That would
> free up one flag bit -- perhaps usable for that BaseException flag Guido
> wants.  :)

:-)  Right, I'm not using the bit currently.  I was thinking that it
would be interesting to change the CheckExact versions to also use
this.  It's a little more work, but you lose the second comparison for
Check.  I expect that it would be slower, but I was just curious.

So with the patch we currently have:

#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type)
#define PyInt_Check(op) (PyInt_CheckExact(op) || \
                 PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS))

But we could have something like:

#define PyInt_CheckExact(op) (PyType_FastClass(op,Py_TPFLAGS_INT_CLASS))
#define PyInt_Check(op) (PyType_FastSubclass(op,Py_TPFLAGS_INT_SUBCLASS))

It would change the CheckExact()s from: op->ob_type ==
global-variable, to: op->ob_type & CONSTANT == CONSTANT.  Check would
be the same as the CheckExact, just with different constants.  The
Check version would then drop the || condition.

I might play with this at the sprint next week.  It does seem to make
sense to do BaseException too.  It will take 4 or 5 bits to handle the
current ones plus BaseException, which we can easily spare in
tp_flags.

n
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to