Path: csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'nicely': 0.07; 'wrapper': 0.07; 'api': 0.09; 'executes': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'python': 0.11; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'readability.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'developer,': 0.18; 'stefan': 0.18; 'extension': 0.20; 'bit': 0.23; 'module': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'points': 0.27; 'module.': 0.27; 'fighting': 0.29; 'usable': 0.29; 'too.': 0.30; 'becomes': 0.31; "i'd": 0.31; 'code': 0.31; 'core': 0.32; '[1]': 0.32; 'computing': 0.32; 'integration': 0.34; 'file': 0.34; 'to:addr:python-list': 0.35; 'reply.': 0.35; 'but': 0.36; 'url:org': 0.36; 'thanks': 0.36; 'faster': 0.36; 'subject:: ': 0.37; 'received:org': 0.38; 'end': 0.39; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'build': 0.40; 'where': 0.40; 'subject:with': 0.40; 'received:de': 0.40; 'some': 0.40; 'learn': 0.60; 'your': 0.60; "you'll": 0.61; 'fun': 0.61; 'more': 0.62; 'interest': 0.64; 'wish': 0.72; 'battle': 0.84; 'url:tutorial': 0.91; 'interesting,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Stefan Behnel Subject: Re: Building an extension module with SWIG Date: Sun, 31 May 2015 07:28:45 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: ipservice-092-211-042-169.092.211.pools.vodafone-ip.de User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433050134 news.xs4all.nl 2845 [2001:888:2000:d::a6]:60091 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91564 garyr schrieb am 30.05.2015 um 22:48: > *snip* > >> Compile it ("cythonize -b foo.pyx") and you'll get an extension module >> that >> executes faster than what SWIG would give you and keeps everything in one >> file to improve readability. >> >> [1] http://cython.org/ > > Thanks for your reply. My interest is not in computing the gcd but to learn > how build an extension module. I have some much more complicated C code I > wish to use. You can do that with Cython, too. http://docs.cython.org/src/tutorial/external.html http://docs.cython.org/src/tutorial/clibraries.html I might be a bit biased as a core developer, but if the parts of you C library's API for which you have an immediate use are not so tremendously huge that it's entirely infeasible for you to write a nicely usable Python API for them, I'd always recommend using Cython over a wrapper generator like SWIG. Once you get to the points where it becomes interesting, you'll always end up having more fun writing a Cython based integration layer than fighting your up-hill battle against the way the wrapper generator wants you to design it. Stefan