Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52114
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joshua.landau.ws@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; '*not*': 0.07; '[1,': 0.09; 'posting.': 0.09; 'subject:method': 0.09; 'that).': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'suggest': 0.14; '2.7': 0.14; 'mostly': 0.14; 'posted': 0.15; 'a()': 0.16; 'chris,': 0.16; 'lambda': 0.16; 'objects?': 0.16; 'said.': 0.16; 'subject:class': 0.16; 'typeerror:': 0.16; 'unbound': 0.16; 'sender:addr:gmail.com': 0.17; 'fix': 0.17; 'wrote:': 0.18; 'bit': 0.19; 'passing': 0.19; '>>>': 0.22; 'example': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'cc:2**0': 0.24; 'mention': 0.26; 'suggested': 0.26; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'chris': 0.29; 'forgot': 0.30; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; '"",': 0.31; '3.2': 0.31; 'pickle': 0.31; 'file': 0.32; 'run': 0.32; 'quite': 0.32; '(most': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'advice': 0.35; 'etc': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'explains': 0.36; 'object,': 0.36; 'method': 0.36; 'thanks': 0.36; 'detail': 0.37; 'fact': 0.38; 'recent': 0.39; 'does': 0.39; 'help,': 0.39; 'called': 0.40; 'august': 0.61; "you're": 0.61; 'further': 0.61; 'first': 0.61; 'back': 0.62; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'due': 0.66; '81,': 0.84; 'etc..': 0.84; 'pickled': 0.84; 'played': 0.84; 'subject:Using': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=2IfPYGhGAA2w3s0+CtBsHvOEO74Ddi4qfgGdwBvxeHU=; b=Q1Tl+mPB8itT+gtjj3Ye6dRfF4jXHU4qs8tJdHd1exHvZsSMiNdCUC/KsjFsKAYBRI dRQW0r0JjP+9qQERUcdORGhrHcS8T0cuoyAih0SiDMpCwjGy/haW6KifZsWJmWlpwb5A 8MYIIuSXBxmNepPoB2lqHs0J3Ud1ejUClAFyhI+Z3nTmrtR/Kp37DeIbH3XJQhUK1EUI zy+XnEpbLS85PNja5NV/49iXYEPZCCr4MJgQCHyEDhvRsIjdyR5stQ7VZhKNRx0TcQSo fuTNU+fUJQOG8zUHfP07+5d3kCeqTCJ1cGt8WjEn4fk6prZjVZax10OvZe4pEdFD2fIp KJhA== |
| X-Received | by 10.152.8.228 with SMTP id u4mr704324laa.79.1375858152526; Tue, 06 Aug 2013 23:49:12 -0700 (PDT) |
| MIME-Version | 1.0 |
| Sender | joshua.landau.ws@gmail.com |
| In-Reply-To | <4cff0d5e-33ab-42cd-b6d4-2b4fe235a274@googlegroups.com> |
| References | <96c575da-7601-4023-aa91-e80664f90333@googlegroups.com> <mailman.268.1375810736.1251.python-list@python.org> <4cff0d5e-33ab-42cd-b6d4-2b4fe235a274@googlegroups.com> |
| From | Joshua Landau <joshua@landau.ws> |
| Date | Wed, 7 Aug 2013 07:48:32 +0100 |
| X-Google-Sender-Auth | R4no9TL-2PyBzraMGzKuAo8_iB0 |
| Subject | Re: Using Pool map with a method of a class and a list |
| To | Luca Cerone <luca.cerone@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list <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 | <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.301.1375858161.1251.python-list@python.org> (permalink) |
| Lines | 43 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1375858161 news.xs4all.nl 15956 [2001:888:2000:d::a6]:47758 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:52114 |
Show key headers only | View raw
On 6 August 2013 20:42, Luca Cerone <luca.cerone@gmail.com> wrote: > Hi Chris, thanks > >> Do you ever instantiate any A() objects? You're attempting to call an >> >> unbound method without passing it a 'self'. > > I have tried a lot of variations, instantiating the object, creating lambda functions that use the unbound version of fun (A.fun.__func__) etc etc.. > I have played around it quite a bit before posting. > > As far as I have understood the problem is due to the fact that Pool pickle the function and copy it in the various pools.. > But since the methods cannot be pickled this fails.. > > The same example I posted won't run in Python 3.2 neither (I am mostly interested in a solution for Python 2.7, sorry I forgot to mention that). > > Thanks in any case for the help, hopefully there will be some other advice in the ML :) I think you might not understand what Chris said. Currently this does *not* work with Python 2.7 as you suggested it would. >>> op = map(A.fun,l) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unbound method fun() must be called with A instance as first argument (got int instance instead) This, however, does: >>> op = map(A(3).fun,l) >>> op [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683] Chris might have also been confused because once you fix that it works in Python 3. You will find that http://stackoverflow.com/questions/1816958/cant-pickle-type-instancemethod-when-using-pythons-multiprocessing-pool-ma explains the problem in more detail than I understand. I suggest reading it and relaying further questions back to us. Or use Python 3 ;).
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using Pool map with a method of a class and a list Luca Cerone <luca.cerone@gmail.com> - 2013-08-06 10:12 -0700
Re: Using Pool map with a method of a class and a list Chris Angelico <rosuav@gmail.com> - 2013-08-06 18:38 +0100
Re: Using Pool map with a method of a class and a list Luca Cerone <luca.cerone@gmail.com> - 2013-08-06 12:42 -0700
Re: Using Pool map with a method of a class and a list Joshua Landau <joshua@landau.ws> - 2013-08-07 07:48 +0100
Re: Using Pool map with a method of a class and a list Luca Cerone <luca.cerone@gmail.com> - 2013-08-07 01:33 -0700
Re: Using Pool map with a method of a class and a list Joshua Landau <joshua@landau.ws> - 2013-08-07 10:47 +0100
Re: Using Pool map with a method of a class and a list Luca Cerone <luca.cerone@gmail.com> - 2013-08-07 03:10 -0700
Re: Using Pool map with a method of a class and a list Joshua Landau <joshua@landau.ws> - 2013-08-07 12:53 +0100
Re: Using Pool map with a method of a class and a list Luca Cerone <luca.cerone@gmail.com> - 2013-08-07 15:26 -0700
Re: Using Pool map with a method of a class and a list Joshua Landau <joshua@landau.ws> - 2013-08-07 23:49 +0100
Re: Using Pool map with a method of a class and a list Peter Otten <__peter__@web.de> - 2013-08-07 16:46 +0200
Re: Using Pool map with a method of a class and a list Joshua Landau <joshua@landau.ws> - 2013-08-07 16:52 +0100
Re: Using Pool map with a method of a class and a list Peter Otten <__peter__@web.de> - 2013-08-07 18:15 +0200
Re: Using Pool map with a method of a class and a list Luca Cerone <luca.cerone@gmail.com> - 2013-08-07 16:31 -0700
Re: Using Pool map with a method of a class and a list Luca Cerone <luca.cerone@gmail.com> - 2013-08-06 12:37 -0700
csiph-web