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


Groups > comp.lang.python > #57051

Re: Passing C pionters to Python for use with cffi

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.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 <eric.frederich@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'interpreter': 0.05; 'subject:Python': 0.06; 'compiler': 0.07; 'interpreter.': 0.07; '"c"': 0.09; 'bindings': 0.09; 'used.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'language.': 0.14; "api's": 0.16; 'usable': 0.16; 'void*': 0.16; '(you': 0.16; 'extensions': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'source': 0.25; '&gt;': 0.26; 'extension': 0.26; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; 'am,': 0.29; '8bit%:3': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'reply.': 0.31; 'extending': 0.31; 'writes:': 0.31; 'allows': 0.31; 'run': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'application': 0.37; 'performance': 0.37; 'skip:& 10': 0.38; 'skip:& 20': 0.39; 'skip:p 20': 0.39; 'called': 0.40; 'url:mail': 0.40; 'first': 0.61; 'compiling': 0.84; 'so...': 0.84; 'cast': 0.91; 'good,': 0.91; 'reasoning': 0.91; 'step.': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=3LRGO/cuG5o7i6T8roXWBp7tjEULQjNg50uQ32RIakE=; b=b7p5TSd2FiLiY0CkgIN9lLmJQPgW+2bJ0pMKBGU1I1j75U1TJIDgfMOgjcQhVu7LYu KeQkZ/P2anR+w5K9zprticoL675EcoXjbk8Sj4umwAfSFrbSq6owC4YnZBapBua49HRJ ck5KqmWXIDLszecQSQqdZqPDC1dUTrTHxSaQm6QzNRvlaTT/6AJmFlDY8EnRW3naiwwy 7WlCcPq2brbLY3S0+ax2zu1HotO8xB7S2EWzdO2uzoPTaRiuKxhFqIHgZ+dfDaCYEETl cjPlfxIYoXX7IgfYAzg2j3RJscuXZ7krk6BCooORl+P4tYJotb4FZ12RyOGW+oLhftoe Uwvg==
MIME-Version 1.0
X-Received by 10.58.146.71 with SMTP id ta7mr793910veb.23.1382109074545; Fri, 18 Oct 2013 08:11:14 -0700 (PDT)
In-Reply-To <874n8oibj1.fsf@handshake.de>
References <CAAoZyYMhuKtNsQFX8Sbf07-ozbSMhe9MHLdKmQw_=osh6M3PDg@mail.gmail.com> <874n8oibj1.fsf@handshake.de>
Date Fri, 18 Oct 2013 11:11:14 -0400
Subject Re: Passing C pionters to Python for use with cffi
From Eric Frederich <eric.frederich@gmail.com>
To dieter <dieter@handshake.de>
Content-Type multipart/alternative; boundary=047d7b5d4a306de05e04e905586a
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1230.1382109082.18130.python-list@python.org> (permalink)
Lines 101
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382109082 news.xs4all.nl 15885 [2001:888:2000:d::a6]:39746
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57051

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Dieter,

Thanks for the reply.
I actually have a fully working set of bindings using Cython.
I'm looking to move away from Cython and use cffi.
My reasoning is that with cffi my binding package would be pure python.

Also, I want my all my code to be Python, not Cython.
I don't care about performance or compiling my Python to C so that it can
be used.
I just want usable bindings so that I can write extensions as well as use
an interactive Python interpreter.

So... again, just wondering if Py_BuildValue("(k)", &some_structure); is
the proper way to send a void* over to Python so that cffi can cast and use
it.


On Fri, Oct 11, 2013 at 2:09 AM, dieter <dieter@handshake.de> wrote:

> Eric Frederich <eric.frederich@gmail.com> writes:
>
> > I'm extending an application that supports customization using the C
> > language.
> > I am able to write standalone python applications that use the C API's
> > using cffi.
> > This is good, but only a first step.
> >
> > This application allows me to register code that will run on various
> events
> > but it has to be C code.
>
> You might want to have a look at "cython".
>
> "cython" is a compiler compiling source programs in a Python
> extension into "C". The corresponding "C" functions can
> then be called from "C" (you may need to annotate the
> functions used in this way to get proper "GIL" ("Global Interpreter Lock")
> handling).
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Re: Passing C pionters to Python for use with cffi Eric Frederich <eric.frederich@gmail.com> - 2013-10-18 11:11 -0400

csiph-web