Confused about extending. (SOLVED)

Chris Gonnerman chris.gonnerman at usa.net
Sat Feb 24 09:30:13 EST 2001


Joonas:

Attached are source files smoothing.c (the Python C module source),
Smoothing.py (the testrig), and joonas.cpp (your source code, marked up
by me).

I am posting this to the list also as the code might be instructive, and
also
in the hopes that if I have made any mistakes someone else might notice
them.

Read the markup in joonas.cpp; I think you have a logic error in your
function, as the last two values in the result list are never assigned by
the
smoothing function but you print them out as if you expect the values to be
meaningful.  (The number of values left unassigned appears to be filterSize
- 1).

The marked-up joonas.cpp (which initializes smoothedList to all zeros)
produces the same values as Smoothing.py with the smoothing.so module,
so I assume my code is correct.

I have been getting a headache reading the Python C API document.
IMHO the question of whether or not the *_SetItem functions "steal" the
reference I give them or not should be explained at least briefly in the
descriptive text of the function itself.  I don't THINK I am leaking
references (and/or memory) in the smoothing.c code but an expert might
be kind enough to double check for me.

Anyway, here they are.  You will need to find the Makefile.pre.in file for
your version of Python, put it in the folder with these files, and do:

    make -f Makefile.pre.in boot
    make

Makefile.pre.in is in /usr/lib/python1.5/config, but your mileage may vary.

If everything is cool you will wind up with smoothing.so (and a lot of other
junk you don't really need).  Look in Smoothing.py for an example of use.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: joonas.cpp
Type: application/octet-stream
Size: 1213 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20010224/5e4aa977/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: smoothing.c
URL: <http://mail.python.org/pipermail/python-list/attachments/20010224/5e4aa977/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Smoothing.py
URL: <http://mail.python.org/pipermail/python-list/attachments/20010224/5e4aa977/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Setup.in
Type: application/octet-stream
Size: 31 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20010224/5e4aa977/attachment-0001.obj>


More information about the Python-list mailing list