Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10374

Re: seeking an example on C extension works in python 3.1.x or above

From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: seeking an example on C extension works in python 3.1.x or above
Date 2011-07-27 08:55 +0200
References <20110727080557.194B.1CBB3534@gmail.com> <j0nut4$iln$1@dough.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.1528.1311749763.1164.python-list@python.org> (permalink)

Show all headers | View raw


Terry Reedy, 27.07.2011 04:58:
> On 7/26/2011 8:06 PM, llwaeva...@gmail.com wrote:
>> I have been searching the example on C extension that works in python
>> 3.1.x
>
> All the stdlib modules written in C. These are extension modules that come
> with Python. There are perhaps a hundred more on PyPI.

Or hundreds.

337 x C
http://pypi.python.org/pypi?:action=browse&c=181

115 x C++
http://pypi.python.org/pypi?:action=browse&c=183

39 x Cython
http://pypi.python.org/pypi?:action=browse&c=536

And that only includes those that properly state their implementation 
language (but I assume that's the large majority).

I also (biasedly) second Dan's recommendation of using Cython instead of C, 
as that substantially reduces the chance of producing portability problems 
in the first place. It also substantially lowers the barrier of having to 
learn much about CPython's C-API and the inner workings and differences of 
CPython versions (at least at the C level).

In case the question was about porting existing C code (the OP wasn't clear 
here), it's sometimes even faster to rewrite the code (or at least the glue 
code) in Cython than to port it to CPython 3.x. And the investment is a 
rather good bargain for reducing the future maintenance cost.

Stefan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: seeking an example on C extension works in python 3.1.x or above Stefan Behnel <stefan_ml@behnel.de> - 2011-07-27 08:55 +0200

csiph-web