Python C module questions
rkern at ucsd.edu
Fri Sep 2 06:18:46 CEST 2005
>>You probably shouldn't post such large pieces of code to the list.
BTW, please attribute your quotes.
>>You mean a docstring on the module object itself?
> Actually, I meant docstrings to the module and the functions, objects,
> methods, whatever else in the module. My code was derived from the
> Python Cookbook, which left that part out (rather important for
> building real C modules).
In the method definition tables for top-level functions and type methods
there is a place for the docstrings. You had them in your code.
Please read the documentation on writing extensions.
[Thomas Heller wrote:]
>>You should give up C with a dumb algorithm running at fast speed.
>>Implement a better algorithm in Python, maybe you can even outperform
>>the dumb code.
> That would be the next step if I needed even more speed, but the better
> algorithm here would be to use KDTrees, which would be overkill (and
> would require lots of development time).
Not for you, it won't.
> The C brute force
> implementation runs plenty fast for me. It took only took a few hours
> to implement and yielded a factor of 7 performance increase. I was
> mostly interested in feedback on whether I had done things in a
> properly efficient way (there are so many Python list / tuple /
> sequence functions). I also find it hard to believe that there's no
> standard Python function for converting sequences of one object to
> arrays in C (a friend mentioned that Ruby's C API has this).
> Another question: how does the distutils package handle version
> upgrades? Say for example I find some bugs in my C code and need to
> recompile it, will it just overwrite what's present in the
> site-packages directory?
It will overwrite the files that have been changed.
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list