Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev
Calling Methods from Pythons C API with Keywords
 

Index | Next | Previous | View Flat


cbarton at metavr

Jun 19, 2007, 7:21 AM


Views: 673
Permalink
Calling Methods from Pythons C API with Keywords

Hey Guys,

My first post on this list so I hope this is the right place to post and
relevant.
Im rewriting parts of the Blender3D python API that has got a bit old
and needs an update.

Im making a PyList subtype with the C/Python API, this involves
intercepting calls to standard list methods to make sure Blenders array
data is in Sync with the list's data.

Iv got it working for tp_as_sequence, tp_as_mapping, iter and dealloc
etc but methods are a problem.

I want to add my own call's before and after PyLists standard functions
but have a proplem with functons that use keywords and have no API
equivalent.
For example, I cant use the API's PyList_Sort because that dosnt support
keywords like...

ls.sort(key=lambda a: a.foo))

And the Problem with PyObject_CallMethod is that it dosnt accept keywords.

PyObject_CallMethod((PyObject *)mylist, "sort", "O", args);


Looking at abstract.c, PyObject_CallMethod uses call_function_tail,
which calls "PyObject_Call(callable, args, NULL);" - so Its not
currently possible with PyObject_CallMethod.

But I cant find any way to do this in a few lines.

I could use PyEval_CallObjectWithKeywords but that would mean Id need to
get the method from the list manually which Ill look into, but unless Im
missing something here, it seems PyObject_CallMethodWithKeywords would
be a nice addition to the Python API that cant be done in a straight
forward way at the moment.

- Thanks


_______________________________________________
Python-Dev mailing list
Python-Dev[at]python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Subject User Time
Calling Methods from Pythons C API with Keywords cbarton at metavr Jun 19, 2007, 7:21 AM
    Re: Calling Methods from Pythons C API with Keywords hrvoje.niksic at avl Jun 20, 2007, 12:34 AM
        Re: Calling Methods from Pythons C API with Keywords cbarton at metavr Jun 20, 2007, 3:17 AM
            Re: Calling Methods from Pythons C API with Keywords hrvoje.niksic at avl Jun 20, 2007, 4:38 AM
                Re: Calling Methods from Pythons C API with Keywords cbarton at metavr Jun 20, 2007, 5:12 AM
                    Re: Calling Methods from Pythons C API with Keywords hrvoje.niksic at avl Jun 20, 2007, 6:00 AM
                    Re: Calling Methods from Pythons C API with Keywords martin at v Jun 20, 2007, 10:26 AM
                        Re: Calling Methods from Pythons C API with Keywords hrvoje.niksic at avl Jun 21, 2007, 4:33 AM
                            Re: Calling Methods from Pythons C API with Keywords cbarton at metavr Jun 21, 2007, 4:59 AM
                            Re: Calling Methods from Pythons C API with Keywords martin at v Jun 21, 2007, 10:25 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.