[Python-Dev] optimizing non-local object access
Thu, 9 Aug 2001 15:17:45 -0500
On Thu, Aug 09, 2001 at 03:15:24PM -0500, Skip Montanaro wrote:
> Jeff> The real gain comes when you can hoist the type test out of the
> Jeff> loop (though that means proving the type condition is an invariant
> Jeff> of the loop!)
> Even more difficult if the programmer can subclass ints, yes?. Today, if I
> see x=x/2 and I know x is an int, I can assume x/2 is also (or a float once
> integer division returns floats). Once ints can be subclassed, a devious
> programmer could return something other than an int (say, a float, a
> rational, or the string "x/2").
Then the test becomes 'x.__class__ is int', not 'isinstance(x, int)'.