[Cython] CEP1000: Native dispatch through callables
stefan_ml at behnel.de
Fri Apr 13 11:35:18 CEST 2012
Dag Sverre Seljebotn, 13.04.2012 11:13:
> On 04/13/2012 07:24 AM, Stefan Behnel wrote:
>> Dag Sverre Seljebotn, 13.04.2012 00:34:
>> There's PEP 362 which proposes a Signature object. It seems to have
>> attracted some interest lately and Guido seems to like it also. I think we
>> should come up with a way to add a C level interface to that, instead of
>> designing something entirely separate.
> Well, provided that you still want an efficient representation that can be
> strcmp-ed in dispatch codes, this seems to boil down to using a Signature
> object rather than a capsule (with a C interface), and store it in
> __signature__ rather than __fastcall__, and perhaps provide a slot in the
> type object for a function returning it.
Basically, yes. I was just bringing it up because we should keep it in mind
when designing a solution. Moving it into the Signature object would also
allow C signature introspection from Python code, for example. It would
obviously need a straight C level way to access it.
I'm not sure it has to be a function, though. I would prefer a simple array
of structs that map signature strings to function pointers. Like the
> I really think the right approach is to prove the concept outside of the
> standardization process first; a) by the time a PEP would be accepted it
> will have been years since Travis had time to work on this, b) as far as
> the slot in the type object goes, we're left with users on Python 2.4
> today; a Python 3.4+ solution is not really a solution.
Sure. But nothing keeps us from backporting at least parts of it to older
Pythons, like we did for so many other things.
More information about the cython-devel