Closed beaylott closed 7 years ago
I have added a Python API which uses the C API + ctypes. It seems to work in the context of the template I have provided. It is likely quite buggy so will update as it is tested.
Hi Ben,
This seems like good stuff but I'm not really sure what it is :-) I was thinking it might be a good idea to have a chat about it and then I'd probably happily merge it.
On Thu, Apr 10, 2014 at 5:08 AM, Ben Aylott notifications@github.comwrote:
I have added a Python API which uses the C API + ctypes. It seems to work in the context of the template I have provided. It is likely quite buggy so will update as it is tested.
Reply to this email directly or view it on GitHubhttps://github.com/eggplantbren/DNest3/pull/10#issuecomment-39989820 .
Dr Brendon J. Brewer Department of Statistics, The University of Auckland, New Zealand Ph: +64 27 500 1336 Web: http://www.stat.auckland.ac.nz/~brewer/
Yes definitely, it still needs work anyway. It mainly just allows for library calls from C code (which also facilitates interaction with Python and other glue languages through FFI). The api.cpp file implements functions and data structures which can be linked with C as well as the CModel callback infrastructure. The DNest3.h defines the public C API.
The addition of the factory pattern (whether in SamplerImpl.h or DNest3.h) is one way for new instances of the models have the callbacks into the C code. There are other ways of doing it but this is the cleanest.
The Python stuff is mainly just there as an example of how the C API can be used. But I am currently investigating using cffi in conjunction with this as it has support for threading and requires less boiler plate code (such as that found in dnest3.py) .
Hi Brendon,
I thought I would at least make you aware of some simple additions to DNest3 to support interaction with C code (via callbacks) and implementing creation by factory for the model classes. Please feel free to incorporate this if wanted.
Keep up the good work!
regards, Ben Aylott