Creating custom Python objects from C code

Eric Frederich eric.frederich at gmail.com
Wed Jan 5 15:46:44 EST 2011


On Wed, Jan 5, 2011 at 11:39 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Wed, 5 Jan 2011 11:27:02 -0500
> Eric Frederich <eric.frederich at gmail.com> wrote:
>> I have read through all the documentation here:
>>>>     http://docs.python.org/extending/newtypes.html
>>>> I have not seen any documentation anywhere else explaining how to
>> create custom defined objects from C.
>> I have this need to create custom objects from C and pass them as
>> arguments to a function call.
>> What do you mean? Create instances of a type defined in Python code?
>> The C API is not very different from Python-land. When you want to
> instantiate a type, just call that type (as a PyObject pointer) with the
> right arguments (using PyObject_Call() and friends). Whether that type
> has been defined in C or in Python does not make a difference.

No, the custom types are defined in C.
I need to create the objects in C.
I need to pass those custom C objects created in C to a python
function via PyObject_CallObject(pFunc, pArgs).


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /