|
From: | Chris Cameron |
Subject: | Re: [igraph] Using iGraph API in Python C module |
Date: | Fri, 22 May 2015 22:09:36 -0400 |
Dear Tamas - Thanks for the reply. I got a basic sample working that sends the result of g.__graph_as_cobject() from Python to C and casts that pointer it an igraph_t*. I think this means the pointer reference is borrowed and that I can avoid managing de-referencing in the C code but I still need to test for memory leaks. I don’t understand the relative advantages of raw_pointer() vs graph_as_cobject(). If PyIGraph_ToCGraph() is the preferred method, I wish the igraphmodule_api.h was distributed with the iGraph C library so it would be in a standard location <igraph/igraphmodule_api.h> . An alternative would be to provide a function like numpy.distutils.misc_util.get_numpy_include_dirs() that returns the install path for python iGraph. I think this would make the setup.py for iGraph-based extensions more portable. The linked git shows a way to use C-iGraph functions on a graph created in Python and how to return computation results as both floats and numpy arrays. The numpy arrays are created in Python and filled by the C code. It is rough code, pieced together from many sources, and the sample computations are trivial examples. I would welcome feedback that improves code quality or implements better practices. Thanks, Chris |
[Prev in Thread] | Current Thread | [Next in Thread] |