Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81849
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; ';-)': 0.03; 'subject:Python': 0.06; 'variables': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrapper': 0.09; 'python': 0.11; 'approaches.': 0.16; 'c++.': 0.16; 'ctypes.': 0.16; 'experiments': 0.16; 'lambda': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'runtime.': 0.16; 'try?': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'numerical': 0.19; 'later': 0.20; 'seems': 0.21; 'python?': 0.22; 'header:User-Agent:1': 0.23; 'questions:': 0.24; 'math': 0.24; 'cheers,': 0.24; 'compare': 0.26; 'compiled': 0.26; 'nearly': 0.26; 'pass': 0.26; 'certain': 0.27; 'developing': 0.27; 'header:X-Complaints-To:1': 0.27; 'testing': 0.29; 'michael': 0.29; 'work.': 0.31; 'code': 0.31; 'ctypes': 0.31; 'extending': 0.31; 'class': 0.32; 'another': 0.32; 'quite': 0.32; 'implemented': 0.33; 'classes': 0.35; 'possible.': 0.35; 'something': 0.35; 'computing': 0.35; 'but': 0.35; 'c++': 0.36; 'functions.': 0.36; 'library.': 0.36; 'much.': 0.36; 'method': 0.36; 'hi,': 0.36; 'should': 0.36; 'two': 0.37; 'easily': 0.37; 'thank': 0.38; 'to:addr:python-list': 0.38; 'little': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'read': 0.60; 'problems.': 0.60; 'helps': 0.61; 'new': 0.61; 'our': 0.64; 'hints': 0.68; 'results': 0.69; 'loose': 0.84; 'try,': 0.84; 'approach.': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Sturla Molden <sturla.molden@gmail.com> |
| Subject | Re: Python, C++ interaction |
| Date | Wed, 3 Dec 2014 10:15:41 +0000 (UTC) |
| References | <547EC9E2.8070502@perfect-kreim.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | 151-68-11.connect.netcom.no |
| User-Agent | NewsTap/4.0.1 (iPad) |
| X- | |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16524.1417601758.18130.python-list@python.org> (permalink) |
| Lines | 56 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1417601758 news.xs4all.nl 2917 [2001:888:2000:d::a6]:33630 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:81849 |
Show key headers only | View raw
Cython is nearly always the answer to scientific computing in Python, including wrapping C++. Sturla Michael Kreim <michael@perfect-kreim.de> wrote: > Hi, > > we are working on a small scientific program that helps us in developing > and testing of new numerical methods for a certain type of biochemical > problems. I spare you the math ;-) > > We code our new methods in Python and compare them with the existing > methods. Unfortunately, these existing methods are quite slow and need a > lot of runtime. Therefor we implemented them in C++. > > Now, we like to combine these two approaches. So we can develop a new > method in Python and compare it easily with the results from the C++ > functions. > > I did some googleing on extending Python by C++ code but I did not find > something that satisfies me. I gave SWIG a try, but several webpages > disadvised me of using it. Also my small experiments did not work. Now, > I read about ctypes. But as far as I understood it, I have to write a C > wrapper for my C++ code and then a Python wrapper for my C code. That > seems a little complicated. > > My C++ code is structured as a class that contains several variables and > functions. Then everything is compiled as a shared library. I can write > things like: > > MyClass.initialvalue = 5; > MyClass.timestep = 0.1; > ... > MyClass.solve(); > > I would like to keep this structure in python, but if I understand > ctypes correctly I would loose the class approach. > > So after the long writeup I come to my questions: > > What are you using to wrap C++ classes for Python? > Can you recommend swig? Should I give it another try? > Did I misunderstood ctypes? > > Also later on in our code development we would like to pass python > lambda functions to C++. So far I understood that this seems not to be > possible. Do you have any ideas or hints on this topics? > > Thank you very much. > > Cheers, > > Michael
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Python, C++ interaction Sturla Molden <sturla.molden@gmail.com> - 2014-12-03 10:15 +0000
csiph-web