Best practices for an inheritance set of classes to do inlining of a class method

15 views
Skip to first unread message

Adam Li

unread,
Mar 1, 2024, 11:30:27 PMMar 1
to cython-users
Hi,

I have a set of classes that do some computation:

```
cdef class A:
    cdef func(self, ...):
         do_something()

cdef class B(A):
     # inherits func exactly

cdef class C(A):
     # want to override func
     cdef func(self, ...):
           do_something_else()
```

The issue is that without class C, I would be able to just `inline` the `func` in class A, and gain considerable speedup since `func` is called MANY times. However, since I want to override func in class C, I end up not being able to have this be inlined.

I realize overriding an inline function in Cython is not supported, so I am wondering:

1. Is there a roadmap to be able to support this feature?
2. If not, what are some design strategies that I can take so that way class C is not hit with the overhead of repeatedly calling `func`?

Thanks for the help!
Reply all
Reply to author
Forward
0 new messages