[capi-sig] PyFunction_New examples

Campbell Barton ideasman42 at gmail.com
Tue Apr 7 04:20:48 CEST 2009


Hi there, I never used PyFunction_New()
If you can make the code object on the fly this should be no problem.

I have only used PyCFunction_New(), you can set "self" to be any
PyObject you like (or a tuple of them)
Then your C function will get self as an argument, which can be
different for every instance of your PyCFunction and decide what to do
based on that.

The main problem with PyCFunction_New is that your tied to predefined
C functions.

Another option is to define your own callable PyType.

Sorry I didn't really answer your question but maybe this helps still.

On Mon, Apr 6, 2009 at 8:58 AM, Trigve Siver <trigves at yahoo.com> wrote:
>
> Hi,
> I'm trying to use PyFunction_New() function but I've problem finding out how it
> works. What I'm trying to do is to create python function on the fly and then
> trying to create function object from if via PyFunction_New.
>
> My problems are similar to this:
>
> http://article.gmane.org/gmane.comp.python.general/548300/match=pyfunction_new
>
> Please CC me.
>
> thanks
>
> Trigve
>
>
>
> _______________________________________________
> capi-sig mailing list
> capi-sig at python.org
> http://mail.python.org/mailman/listinfo/capi-sig
>



-- 
- Campbell


More information about the capi-sig mailing list