Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'subject:Python': 0.05; 'cpython': 0.05; 'c++,': 0.07; 'seemed': 0.07; 'api': 0.09; 'python': 0.09; '(but': 0.15; 'apis.': 0.16; 'extensions,': 0.16; 'wrote:': 0.17; 'certainly': 0.17; 'instance,': 0.17; 'module': 0.19; 'code.': 0.20; 'sort': 0.21; 'bit': 0.21; 'import': 0.21; 'assuming': 0.22; "i've": 0.23; 'seems': 0.23; 'idea': 0.24; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; '(which': 0.26; 'wrote': 0.26; '(e.g.': 0.27; 'am,': 0.27; 'c++': 0.27; 'interface': 0.27; 'skip:( 20': 0.28; 'normal.': 0.29; 'restricted': 0.29; 'wrap': 0.29; 'case,': 0.29; 'class': 0.29; 'worked': 0.30; 'e.g.': 0.30; 'code': 0.31; 'not.': 0.32; 'to:addr:python-list': 0.33; 'agree': 0.34; 'there': 0.35; 'but': 0.36; "didn't": 0.36; 'does': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'little': 0.39; 'your': 0.60; 'between': 0.63; 'gave': 0.65; 'natural': 0.65; 'differences': 0.65; 'directly.': 0.78 Date: Tue, 16 Oct 2012 11:42:44 -0500 From: Evan Driscoll User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Re: Providing a Python wrapper to a C++ type. References: <0423426c-c19a-4634-9f67-5bf92d766f61@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350406603 news.xs4all.nl 6906 [2001:888:2000:d::a6]:45133 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31419 [Stefan gave part of an answer here, but I've got an addition too.] On 10/16/2012 6:46 AM, Marco Nawijn wrote: > I never worked with Cython (but I know it is very powerful and interesting) but in my mind there are slight differences in usage scenario between e.g. Boost Python and Cython. For me the idea of Cython is that your main code is in Python, but you want to improve the performance of specific parts of the code. In that case, Cython is the way to go. In case of Boost Python, the scenario for me is that you have a main program/library in C++, but you want to be able use the functionality from Python. > > Do you agree with this view? Sort of, but sort of not. I've only used Cython a little bit, but it seems to work equally well if you want to write a C module for some reason (e.g. to interface with existing C code) but don't want to deal with the standard CPython C API directly. For instance, I used it to wrap the OS's opendir/readdir (FindFirstFile/FindNextFile) functions: I just wrote a bit of code using Cython's extensions, and I get a module I can import and use as normal. I certainly didn't do it for speed, I did it because it seemed like a reasonable way to get access to those APIs. (ctypes was insufficient for my needs.) So wrapping a C++ class using Cython also seems pretty natural to me, assuming that Cython does OK with C++ and isn't restricted to C (which I have no idea about). Evan