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


Groups > comp.lang.python > #52061

Re: Using Pool map with a method of a class and a list

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.046
X-Spam-Evidence '*H*': 0.92; '*S*': 0.01; 'argument': 0.05; 'versions,': 0.07; 'subject:method': 0.09; 'python': 0.11; 'def': 0.12; 'a()': 0.16; 'a(object):': 0.16; 'bit.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'objects?': 0.16; 'subject:class': 0.16; 'unbound': 0.16; 'wrote:': 0.18; 'passing': 0.19; 'import': 0.22; 'aug': 0.22; 'header:In-Reply-To:1': 0.27; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; 'class': 0.32; 'skip:_ 10': 0.34; 'subject:with': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'simply': 0.61; "you're": 0.61; 'first': 0.61; 'different': 0.65; 'between': 0.67; 'results': 0.69; 'around,': 0.84; 'different.': 0.84; 'self.value': 0.84; 'subject:Using': 0.84; 'carries': 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 :content-type; bh=BUfMrUQtAnGf67gDXUeVEx4BRwBU58y+3XdyQ6akudQ=; b=K56Zz/XaamwAZovJaWRJ45egp84rUyVbzvp8bb4D5ORA/R7uMsaeOHxEa42MrGWRwq pK0Ok1m4n74Jnd/+EaYEjDub5GZiwQiNlnjHhv9ePiWtou5GBO+2uojbFhVGXJU+/X0a 55RnDMBzHBNA55KYIjc/7iaN2/yZbjtranZue+zfxTFDJlaofRi+LozeLqjr1kb2xtd4 j5nC5kYxHK4HsZ88qlbjL79tSD5oxJ2vyzIrvcUYtYy5Ynud3DLHNQFBDmEf+BcxxDBx LWtEs1iS1BSqp2+GqkctmUehxyV0mPwphk5J67hiJWd512sAkMHT19rSr2a9sgj0q3FG r72Q==
MIME-Version 1.0
X-Received by 10.52.89.170 with SMTP id bp10mr591099vdb.104.1375810734537; Tue, 06 Aug 2013 10:38:54 -0700 (PDT)
In-Reply-To <96c575da-7601-4023-aa91-e80664f90333@googlegroups.com>
References <96c575da-7601-4023-aa91-e80664f90333@googlegroups.com>
Date Tue, 6 Aug 2013 18:38:54 +0100
Subject Re: Using Pool map with a method of a class and a list
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.268.1375810736.1251.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375810736 news.xs4all.nl 15921 [2001:888:2000:d::a6]:54019
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52061

Show key headers only | View raw


On Tue, Aug 6, 2013 at 6:12 PM, Luca Cerone <luca.cerone@gmail.com> wrote:
> from multiprocessing import Pool
>
> class A(object):
>    def __init__(self,x):
>        self.value = x
>    def fun(self,x):
>        return self.value**x
>
>
> l = range(10)
>
> p = Pool(4)
>
> op = p.map(A.fun,l)

Do you ever instantiate any A() objects? You're attempting to call an
unbound method without passing it a 'self'.

You may find the results completely different in Python 2 vs Python 3,
and between bound and unbound methods. In Python 3, an unbound method
is simply a function. In both versions, a bound method carries its
first argument around, so it has to be something different. Play
around with it a bit.

ChrisA

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


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