[Cython] CEP1000: Native dispatch through callables

Stefan Behnel stefan_ml at behnel.de
Fri Apr 13 14:48:05 CEST 2012

Stefan Behnel, 13.04.2012 14:27:
> Dag Sverre Seljebotn, 13.04.2012 13:59:
>> Requiring interning is somewhat less elegant in one way, but it makes a lot
>> of other stuff much simpler.
>> That gives us
>> struct {
>>     void *pointer;
>>     PyBytesObject *signature;
>> } record;
>> and then you allocate a NULL-terminated arrays of these for all the overloads.
> However, the problem is the setup. These references will have to be created
> at init time and discarded during runtime termination. Not a problem for
> Cython generated code, but some overhead for hand written code.
> Since the size of these structs is not a problem, I'd prefer keeping Python
> objects out of the game and using an ssize_t ID instead, inferred from a
> char* signature at module init time by calling a C-API function. That
> avoids the need for any cleanup.

Actually, we could even use interned char* values. Nothing keeps that C-API
setup function from reassigning the "char* signature" field to the char*
buffer of an internally allocated byte string. Except that we'd have to
*require* users to use literals or otherwise statically allocated C strings
in that field. Hmm, maybe not the best idea ever...


More information about the cython-devel mailing list