--
---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cython-users/2b2f2469-f1b4-4fd8-ad2b-7376aea4a9d9n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cython-users/88a0243c-8dde-99da-c9ab-d23f8b330461%40d-woods.co.uk.
The creation of this is actually to deal w/ this:
i.e I want to enjoy the benefit of a static typed “c bounded function” (although there’s no such thing).
I think you're misunderstanding what that issue will actually do. Creating a "bound C function" creates a Python wrapper (both with and without the improvement proposed there). If you're calling your bound C functions that way then you should probably just write a regular "def" function because there's actually no difference (except that you've also imposed all the limitations of a cdef function). That issue proposes binding them in a slightly quicker way but doesn't change that much.
The actual value passed in will be any Service or derived class of Service object’s function with no arg (so meets the functor type), so arbitrary I guess.
Then my question is - is the any other workaround w/o c functor (the current way) that I can preserve the static type of this cdef “member func” w/o losing the signature entirely (i.e. object), while being able to pickle/serialize?
My best suggestion is that you don't store C function pointers but instead you store cdef classes that all inherit from some common base:
```
cdef class Callable:
cdef void call(self): # or whatever types you actually have
pass
```
You then create a bunch of derived types that inherit from
callable, and are pickleable. Calling `callable_instance.call()`
is quick (although probably not quite as quick as going through a
function pointer). I don't know if that fits into your scheme.
To view this discussion on the web visit https://groups.google.com/d/msgid/cython-users/CAHcVAySfeGcOzEU5UpcCvSCv0AkQKwukiys0LE%3Dh9xTZzZH24A%40mail.gmail.com.