[Python-Dev] Type of range object members (original) (raw)
Neal Norwitz nnorwitz at gmail.com
Thu Aug 17 07:57:54 CEST 2006
- Previous message: [Python-Dev] Type of range object members
- Next message: [Python-Dev] Type of range object members
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 8/16/06, Phillip J. Eby <pje at telecommunity.com> wrote:
It seems to me that you could drop the FASTSUBCLASS 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
- Previous message: [Python-Dev] Type of range object members
- Next message: [Python-Dev] Type of range object members
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]