Ticket #3 (new enhancement)

Opened 8 months ago

Last modified 5 months ago

Cython calls ExtType.__init__() as Python function

Reported by: robertwb Assigned to: somebody
Priority: major Milestone: wishlist
Component: Optimization Version:
Keywords: Cc:

Description

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.

Change History

05/05/2008 05:23:45 PM changed by robertwb

  • owner changed from robertwb to somebody.

05/25/2008 09:35:14 PM changed by gfurnish

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.

08/18/2008 08:56:41 PM changed by robertwb

  • milestone set to wishlist.