[Tutor] Python Extensions in C
James Reynolds
eire1130 at gmail.com
Thu May 26 17:22:54 CEST 2011
Hello All:
As an intellectual exercise, I wanted to try my hand at writing some
extensions in C.
I was wondering if you all could look over my code and give some feedback.
Here is the link for the code: http://pastebin.com/jw3ihfsN
I have zero experience coding in C (and not much more coding in Python!).
Being a kinetic learner, I thought this would be a good exercise to teach me
some of the underpinnings of Python, how it works, why it works the way it
does, and as an added bonus, skills to actually write my own extensions if I
ever wanted to.
I had to learn about pointers to do this, and I'm still not 100% on if I
used them correctly herein.
I am also very concerned with memory management because I am not sure when I
should be calling the memory allocation macros to decref or incref when
needed.
I would also like to get feedback on how I am constructing C algorithms.
As far as the module itself goes, I was able to compile and use it on a
windows machine compiling with mingw (I use distutils to do the work, so for
me I do "python setup.py build" in my CMD.
There are three functions, stats.mean, stats.var, stats.stdev (and they do
what you would expect). One thing though, these are the "population"
statistics and not "sample" in case you want to test it out.
Also, anything else that you think would be worthwile pointing out, tips and
tricks, common pitfalls, etc.
Thanks in advance for you feedback.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110526/fdea08aa/attachment.html>
More information about the Tutor
mailing list