Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'arguments': 0.05; 'callable': 0.09; '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; 'tuple': 0.09; 'tuple.': 0.09; 'underlying': 0.09; 'written': 0.12; 'am,': 0.14; 'extension': 0.14; 'wrote:': 0.14; 'called,': 0.16; 'enigma': 0.16; 'kern': 0.16; 'pyobject*': 0.16; 'received:216.62': 0.16; 'received:216.62.213': 0.16; 'received:enthought.com': 0.16; 'interpret': 0.19; 'greatly': 0.20; 'header:In-Reply-To:1': 0.22; 'itself.': 0.22; 'define': 0.26; 'specifically': 0.27; 'stefan': 0.29; 'probably': 0.30; 'skip:( 20': 0.31; 'does': 0.31; 'all,': 0.31; 'to:addr:python- list': 0.32; 'header:X-Complaints-To:1': 0.34; 'returned': 0.35; 'header:User-Agent:1': 0.35; 'appreciated.': 0.36; 'rest': 0.37; 'should': 0.37; 'but': 0.38; 'received:org': 0.38; 'though': 0.38; 'docs': 0.39; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'takes': 0.40; 'attempt': 0.40; 'would': 0.40; 'header:Received:5': 0.40; 'give': 0.61; 'our': 0.63; 'world': 0.65; 'believe': 0.66; '11:48': 0.84; 'eco': 0.84; 'often,': 0.84; 'subject:types': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: Pickling extension types Date: Tue, 03 May 2011 12:10:23 -0500 Organization: The Church of Last Thursday References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: outbound.enthought.com User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: 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: 22 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304442645 news.xs4all.nl 81479 [::ffff:82.94.164.166]:34962 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4558 On 5/3/11 11:48 AM, Stefan Kuzminski wrote: > Hi all, > > I have an extension type written in C, but I cannot get it to pickle, any > insights would be greatly appreciated. > > I see in the docs that I should define a __reduce__ method and that does get > called, but I don't know specifically the type of the 'callable object' that > should be the first thing in the tuple returned by __reduce__. It should be a callable PyObject* that takes the arguments given in the rest of the tuple. Often, this is just the type itself. So probably (PyObject*)PyMV_Type, if you give the right arguments in the rest of the tuple. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco