On 13 April 2012 13:48, Stefan Behnel <stefan...@behnel.de> wrote: > 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... > > Stefan > _______________________________________________ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel
You could create a module shared by all versions and projects, which exposes a function 'get_signature', which given a char *signature returns the pointer that should be used in the ABI signature type information. You can then always compare by identity. _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel