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


Groups > comp.lang.python > #8605

Re: keeping local state in an C extension module

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <franke.daniel@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.036
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'subject:module': 0.04; 'reference:': 0.07; 'python': 0.08; 'deprecated': 0.09; 'variables.': 0.09; 'api': 0.11; 'static': 0.16; 'cc:addr:python- list': 0.16; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'works.': 0.23; 'missed': 0.24; 'concern': 0.28; 'message-id:@mail.gmail.com': 0.28; 'stefan': 0.29; '"the': 0.29; 'cc:addr:python.org': 0.30; 'thanks': 0.31; 'too': 0.32; 'there': 0.34; 'daniel': 0.34; 'option.': 0.35; 'switch': 0.35; 'idea': 0.36; 'but': 0.37; 'another': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'somewhat': 0.38; 'might': 0.39; 'received:209': 0.40; 'your': 0.60; 'back': 0.63; 'here': 0.66; 'note:': 0.68; 'received:209.85.216.174': 0.73; '2.7.': 0.84; 'subject:local': 0.84; 'ugly,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=VSuLDK+Lotwe0wrm490JoCQ9x/6FD3GU1za9oK/OPIA=; b=GAbn8Hn7vWEHfq2wgGN0KPXeP+B1eTZ0cSf1Nga//IsZGu0RB1C9DYaodctmJW57QE hMnoiDmUunxaMLZfblNPBNZcvWPuLY1jyGFltvlOC+vvLU+iA+V0cljrdHWCGzdpGMDJ SD1/ssrUBC5ewx/G2QNRPs4kpMY9v106YfRdE=
MIME-Version 1.0
In-Reply-To <iuhsk0$grk$1@dough.gmane.org>
References <CAJ+j52Ye6s02v7i7D+U-qNWCEFMc_gaOJJgV2Xjvd1TaovzMoQ@mail.gmail.com> <iuhj82$mgf$1@dough.gmane.org> <CAJ+j52YYLormXbmSfdT7fRxE4sO2UjMSSNQQgMkKDNY1PpufFQ@mail.gmail.com> <iuhsk0$grk$1@dough.gmane.org>
Date Thu, 30 Jun 2011 15:19:44 +0200
Subject Re: keeping local state in an C extension module
From Daniel Franke <franke.daniel@gmail.com>
To Stefan Behnel <stefan_ml@behnel.de>
Content-Type text/plain; charset=ISO-8859-1
Cc python-list@python.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.524.1309439986.1164.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1309439986 news.xs4all.nl 21800 [2001:888:2000:d::a6]:58963
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8605

Show key headers only | View raw


2011/6/30 Stefan Behnel <stefan_ml@behnel.de>:
>> If there are too many hoops to jump through to get a reasonable
>> solution working for 2.[567], I might as well go back to
>> Py_InitModule() and static variables. It's somewhat ugly, but it
>> works.
>
> Py2.x has a PyCObject, basically the predecessor to PyCapsule. Writing your
> own little type is another option.

For reference: PyCObject has PyCObject_FromVoidPtr() and
PyCObject_AsVoidPtr() -- exactly what I was looking for (no idea why I
missed it for so long?!). Ok, and it also has the note: "The CObject
API is deprecated as of Python 2.7. Please switch to the new Capsules
API." which is of no concern here :)

Thanks heaps!

     Daniel

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


Thread

Re: keeping local state in an C extension module Daniel Franke <franke.daniel@gmail.com> - 2011-06-30 15:19 +0200

csiph-web