Stefan Behnel, 12.01.2010 16:17:
> Neil Ludban, 12.01.2010 16:11:
>> On Jan 12, 2010, at 9:44 AM, Stefan Behnel wrote:
>>> Sturla Molden, 12.01.2010 14:04:
>>>> I'd like to make a different suggestion. What about a keyword to pass
>>>> after cdef in the declaration of the object to indicate the vtab can
>>>> be skipped? I e an assertion that the object will be of the declared
>>>> type. This will maintain better compatibility with Python.
>>>>
>>>> cdef Foo bar = Foo()
>>>> cdef inline Foo fastbar = bar
>>>>
>>>> bar.method() # through vtab
>>>> fastbar.method() # direct call
>>> Why would you want to control this from user code?
>> It's explicit and selectively breaks Python's semantics as needed
>> for optimization. Much nicer than implicit and global breakage.
>
> You assume that inlining would break things. It can't, given the current
> type instantiation semantics.
Sorry, ignore what I just said. It can, just not in the above example. The
case we are talking about here is this:
cdef MyType x = something_that_returns_some_object()
cdef inline MyType fast_x = x
in which case 'x' may refer to any subtype of MyType, which can obviously
override the methods in MyType.
I'm not sure I'm comfortable with this idea, though. This would allow users
to break into the hierarchy of an existing type by calling a specific
method sort-of half-explicitly. That sounds rather error prone to me. It's
better to keep the control inside of the class definition IMHO.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev