Writing C extensions using direct python api | ![]() |
Alle variablen die intern in einer funktion benutzt werden müssen sofern sie nicht ins python zurückgeliefert werden wieder gelöscht werden. dies geschieht mittels PyObject? -> {Py DECREF}?(variable);
main.c
![]() |
|
setup.py:
![]() |
|
Makefile:
![]() |
|
building | ![]() |
make
Running | ![]() |
![]() |
|
Writing python modules using swig C++ | ![]() |
sample.h
![]() |
|
sample.i
![]() |
|
Makefile
![]() |
|
see swig1.3 sample directory in debian but sample.h is almost all you need
Writing python modules using swig and C | ![]() |
the c File | ![]() |
![]() |
|
the interface file for swig | ![]() |
![]() |
|
make and compile and create the python library | ![]() |
> gcc -c sample.c sample_wrap.c -I/usr/include/python2.3
> ld -shared sample.o sample_wrap.o -o _sample.so -L(librarys)
at last in python | ![]() |
>>> import sample
>>> sample.somefunction()
python memory management | ![]() |
http://evanjones.ca/python-memory.html