2011/8/25 Stefan Behnel <stefan...@behnel.de>: > Vitja Makarov, 25.08.2011 18:11: >> >> 2011/8/24 Stefan Behnel: >>> >>> Vitja Makarov, 24.08.2011 21:17: >>>> >>>> I tried final classes: >>>> 2. In this example foo call is done through virtual table >>>> >>>> cimport cython >>>> >>>> @cython.final >>>> cdef class Foo: >>>> cdef foo(self): >>>> print 'haha' >>>> >>>> def test(): >>>> cdef Foo a = Foo() >>>> a.foo() >>>> >>>> __pyx_t_1 = ((struct __pyx_vtabstruct_3yyy_Foo >>>> *)__pyx_v_a->__pyx_vtab)->foo(__pyx_v_a); if (unlikely(!__pyx_t_1)) >>>> {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = >>>> __LINE__; goto __pyx_L1_error;} >>> >>> Right, this is not implemented yet. Feel free to do so. Also see >>> >>> http://trac.cython.org/cython_trac/ticket/474 >>> >>> >>>> 3. I can't use final decorator for methods (error reported) >>> >>> http://trac.cython.org/cython_trac/ticket/586 >> >> What is the prefered syntax keyword inline or final decorator? > > "final" is the right option here. > > They are orthogonal concepts. Only because you declare a method "final" does > not mean you want to inline it, and just because you declare it "inline" > does not (necessarily) mean that you cannot override it. Admittedly, the > semantics of an overridable inline method may turn out to be somewhat > obscure and error prone, so I think it's a good idea to let "inline" imply > "final". But not the other way round. >
But both inline and final methods should bypass vtab, right? Also I'm not sure about C inline qualifier here. I see three options: - non-virtual: bypass vtab - final: non-virtual, non-overridable - inline: non-virtual, C inline qualifier is used -- vitja. _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel