[Python-Dev] Type of range object members (original) (raw)
Phillip J. Eby pje at telecommunity.com
Wed Aug 16 20:29:30 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 ]
At 11:46 PM 8/15/2006 -0700, Neal Norwitz wrote:
On 8/15/06, "Martin v. Löwis" <martin at v.loewis.de> wrote:
That penalty is already paid today. Much code dealing with ints has a type test whether it's an int or a long. If int and long become subtypes of each other or of some abstract type, performance will decrease even more because a subtype test is quite expensive if the object is neither int nor long (it has to traverse the entire base type hierarchy to find out its not inherited from int). I was playing around with a little patch to avoid that penalty. It doesn't take any additional memory, just a handful of bits we aren't using. :-) For the more common builtin types, it stores whether it's a subclass in tpflags, so there's no function call necessary and it's a constant time operation. It was faster when doing simple stuff. Haven't thought much whether this is really worthwhile or not.
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. :)
(Of course, if you can't inherit from both BaseException and one of the other builtin types, it can just be another enumeration value within the bit mask.)
- 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 ]