Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Creating custom Python objects from C code

Reply
Thread Tools

Creating custom Python objects from C code

 
 
Eric Frederich
Guest
Posts: n/a
 
      01-05-2011
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
 
Reply With Quote
 
 
 
 
Aahz
Guest
Posts: n/a
 
      01-27-2011
In article <mailman.537.1294244829.6505.python->,
Eric Frederich <> 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.


You should definitely investigate Cython, but if you really want to roll
your own, look in the examples inside the Python source itself.
--
Aahz () <*> http://www.pythoncraft.com/

"All problems in computer science can be solved by another level of
indirection." --Butler Lampson
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating garbage collectable objects (caching objects) News123 Python 7 06-29-2009 04:12 PM
Creating custom methods to use with HTML DOM objects bizt Javascript 1 06-03-2008 05:01 PM
Creating Reports with custom objects =?Utf-8?B?R2hpc3Rvcw==?= ASP .Net 3 10-24-2007 05:28 PM
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net 0 06-01-2005 02:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57