Ticket #3 (new enhancement)
Cython calls ExtType.__init__() as Python function
| Reported by: | robertwb | Owned by: | somebody |
|---|---|---|---|
| Priority: | major | Milestone: | wishlist |
| Component: | Optimization | Keywords: | |
| Cc: |
Description (last modified by scoder) (diff)
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.
