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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeder.news-service.com!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(at': 0.03; 'python.': 0.04; 'cpython': 0.05; 'terry': 0.07; 'python': 0.08; 'url:pypi': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'c++': 0.12; 'subject:python': 0.12; 'wrote:': 0.15; 'c-api': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'glue': 0.16; 'pypi.': 0.16; 'subject:example': 0.16; 'workings': 0.16; 'pm,': 0.16; 'written': 0.17; 'rewrite': 0.19; 'language': 0.20; '(but': 0.22; 'extension': 0.22; 'header:In-Reply-To:1': 0.22; 'assume': 0.23; 'versions': 0.23; 'code': 0.24; '(or': 0.25; 'modules': 0.25; '(the': 0.28; 'producing': 0.28; "wasn't": 0.28; 'stefan': 0.29; 'second': 0.29; 'example': 0.30; 'differences': 0.30; 'porting': 0.30; 'least': 0.31; 'rather': 0.33; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'instead': 0.34; 'header:User- Agent:1': 0.34; 'there': 0.34; 'question': 0.35; 'url:python': 0.37; 'using': 0.37; 'received:org': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'problems': 0.38; 'perhaps': 0.39; 'case': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'url:c': 0.72; 'hundred': 0.76; 'investment': 0.78; '337': 0.84; 'lowers': 0.84; 'url:183': 0.84; 'received:93': 0.86; 'reducing': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: seeking an example on C extension works in python 3.1.x or above
Date Wed, 27 Jul 2011 08:55:48 +0200
References <20110727080557.194B.1CBB3534@gmail.com> <j0nut4$iln$1@dough.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host ppp-93-104-28-119.dynamic.mnet-online.de
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11
In-Reply-To <j0nut4$iln$1@dough.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1528.1311749763.1164.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1311749763 news.xs4all.nl 23895 [2001:888:2000:d::a6]:49848
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10374

Show key headers only | 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