On Wed, May 16, 2012 at 11:33 AM, "Martin v. Löwis" <mar...@v.loewis.de> wrote: >> Does this use case make sense to everyone? >> >> The reason why we are discussing this on python-dev is that we are looking >> for a general way to expose these C level signatures within the Python >> ecosystem. And Dag's idea was to expose them as part of the type object, >> basically as an addition to the current Python level tp_call() slot. > > The use case makes sense, yet there is also a long-standing solution already > to expose APIs and function pointers: the capsule objects. > > If you want to avoid dictionary lookups on the server side, implement > tp_getattro, comparing addresses of interned strings.
Yes, that's an idea worth looking at. The point implementing tp_getattro to avoid dictionary lookups overhead is a good one, worth trying at least. One drawback is that this approach does require the GIL (as does _PyType_Lookup). Regarding the C function being faster than the dictionary lookup (or at least close enough that the lookup takes time), yes, this happens all the time. For example one might be solving differential equations and the "user input" is essentially a set of (usually simple) double f(double) and its derivatives. - Robert _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com