Open robertwb opened 8 years ago
Modified by robertwb on 6 May 2008 00:23 UTC
Comment by gfurnish on 26 May 2008 04:35 UTC One of the first things I do is make my own c wrappers for creating objects. Even with the expensive new call the savings it noticeable.
Modified by robertwb on 19 Aug 2008 03:56 UTC
Comment by scoder on 6 Mar 2009 19:49 UTC The same idea is reported in #141. This should use cpdef semantics.
Comment by scoder on 8 Mar 2009 12:04 UTC
The same applies to other special methods like __call__
. (noted here to close #141 as a duplicate)
Comment by scoder on 15 Oct 2011 07:58 UTC The test in tests/run/special_methods_T561.pyx has some test code for this:
https://github.com/cython/cython/commit/6ae02221a00e02fab7756b0856accd2be89f5670
Reported by robertwb on 6 May 2008 00:14 UTC When subclasses of extension types call the init() method of their supertype, Cython generates code that looks up the "init" attribute of the instance and then calls it through Python using arg tuple/kwargs. This is because the special init() method ("tp_init" slot) uses this call signature.
Cython should recognise calls to this method and at least call it directly.
In the (presumably very common) case that the arguments do not use starargs, a more advanced approach would be to split the init() method into an internal plain C-function replacement and a tp_init wrapper, and then call the internal function directly, without doing any tuple packing etc. Not sure if it's worth it, though, as the call is already preceded by an (expensive) object allocation.
Migrated-From: http://trac.cython.org/ticket/3