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: 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: References: Date: Thu, 30 Jun 2011 15:19:44 +0200 Subject: Re: keeping local state in an C extension module From: Daniel Franke To: Stefan Behnel 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 2011/6/30 Stefan Behnel : >> 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