On Sep 24, 2008, at 7:25 PM, Greg Ewing wrote:

> Robert Bradshaw wrote:
>
>> The problem is that isinstance is declared to take an object as the
>> second parameter, and the optimization happens later on.
>
> I'm not sure why you need compiler hackery to do this
> in the first place. Why not just declare isinstance
> in the builtin functions table as the equivalent of
>
>    int isinstance "PyObject_TypeCheck" (object, type)
>
> A runtime type test will get generated if the second
> argument isn't known to be a type, but that's probably
> a good idea anyway, since PyObject_TypeCheck is
> expecting a type and will likely crash if you give
> it something else.

Because isinstance is much more versatile than this, it can take  
tuples, and non-types (though that will raise an error instead of  
crashing). I've optimized the case that the second argument of  
isinstance is of type type only.

When we implement polymorphism, we can do it the "easy" way.

- Robert
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to