On Mon, Nov 12, 2012 at 2:08 AM, Kornél JAHN <
korne...@gmail.com> wrote:
> Hello Stefan!
>
> The user guide states here:
> "Module level functions can now be declared inline, with the inline keyword
> passed on to the C compiler. These can be as fast as macros. [...]
> Note that class-level cdef functions are handled via a virtual function
> table, so the compiler won’t be able to inline them in almost all cases."
>
> Does your comment mean that cdef class methods can be inlined, too, if the
> cdef class is decorated with @cython.final? Hence the last sentence does not
> apply for this case?
>
> I think this information is *very* valuable for those (like me), who need
> speed as well as keeping the code well-structured in cdef classes. It would
> be nice to include this information in the documentation (I could not find
> it anywhere).
I agree, we'd welcome a patch to the documentation.
However, taking a step back (in response to the original post) I would
like to echo the old adage that the first step to optimization is to
profile, profile, profile and then optimize the critical parts.
Sometimes inlining methods can make a difference, but it's surprising
how many times it really isn't the part that matters.