Creating custom Python objects from C code

E

Eric Frederich

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.

Question 1: how am I to create those objects from C code?

The other thing I would like to know is how I can create helper
functions in my extension so they can be created and manipulated
easily.
I am thinking along the lines of the built-in helper functions
PyList_New and PyList_Append.
Once I have an answer to question 1, the problem won't be creating the
helper functions, but making them available from something built with
distutils.
To use the builtin python functions from C I need to link against
python27.lib but when I create my own package using distutils it
creates dll or pyd files.

Question 2: How do I make C helper functions that are part of my
extension available to other C projects in the same way that PyList_*,
PyString_*, PyInt_* functions are available?
Is it possible to have distutils make a .lib file for me?

Thanks,
~Eric
 
A

Aahz

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.

You should definitely investigate Cython, but if you really want to roll
your own, look in the examples inside the Python source itself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top