Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91564
| From | Stefan Behnel <stefan_ml@behnel.de> |
|---|---|
| Subject | Re: Building an extension module with SWIG |
| Date | 2015-05-31 07:28 +0200 |
| References | <mkco9p$gf8$1@speranza.aioe.org> <mailman.229.1433012748.5151.python-list@python.org> <mkd7nk$isi$1@speranza.aioe.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.239.1433050134.5151.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Building an extension module with SWIG "garyr" <garyr@fidalgo.net> - 2015-05-30 09:22 -0700
Re: Building an extension module with SWIG Stefan Behnel <stefan_ml@behnel.de> - 2015-05-30 21:05 +0200
Re: Building an extension module with SWIG "garyr" <garyr@fidalgo.net> - 2015-05-30 13:48 -0700
Re: Building an extension module with SWIG "garyr" <garyr@fidalgo.net> - 2015-05-30 15:55 -0700
Re: Building an extension module with SWIG Stefan Behnel <stefan_ml@behnel.de> - 2015-05-31 07:28 +0200
Re: Building an extension module with SWIG "garyr" <garyr@fidalgo.net> - 2015-05-30 18:54 -0700
csiph-web