Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python': 0.08; '21,': 0.09; 'be:': 0.09; 'subject:method': 0.09; 'am,': 0.12; 'win32': 0.12; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '(lambda': 0.16; 'blacklist': 0.16; 'str(x))': 0.16; 'subject:function': 0.16; 'subject:python.': 0.16; 'subject:release': 0.16; 'cc:addr:python-list': 0.16; 'received:74.125.82.44': 0.16; 'received:mail-ww0-f44.google.com': 0.16; 'wed,': 0.17; 'wrote:': 0.18; '>>>': 0.18; 'functions,': 0.18; 'of.': 0.18; 'seems': 0.20; 'cheers,': 0.20; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'item.': 0.23; "shouldn't": 0.23; 'works.': 0.23; "i'm": 0.26; 'import': 0.27; 'cc:addr:gmail.com': 0.28; 'not.': 0.28; 'bit': 0.28; 'message-id:@mail.gmail.com': 0.28; 'fine.': 0.29; 'cc:addr:python.org': 0.29; 'nov': 0.29; 'get.': 0.30; 'operation.': 0.30; 'subject:support': 0.30; 'version': 0.32; "can't": 0.32; 'there': 0.33; 'received:74.125.82': 0.35; 'cc:2**1': 0.36; 'skip:" 10': 0.37; 'but': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'think': 0.37; 'doing': 0.38; 'subject: (': 0.40; "it's": 0.40; 'might': 0.40; 'more': 0.61; 'type': 0.61; '2011': 0.61; 'your': 0.61; "'1',": 0.84; "'2',": 0.84; "'3',": 0.84; '(your': 0.84; '2.7.1': 0.84; 'me:': 0.84; 'prone': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=GbdSnuOFln6JCRPtwBEQhHSuL0kHWxNQrZM3c4rLn7c=; b=nDHATGycYmNl35k7IFBKa892oYtjs3foxP2Z0iMDmmobxrwAsC3OmxqgfknfR2/3qd vXyBrAWBMgHl4Dm5aHLU6Ga/VykYubC5dYM4195gNAHiY8cf5QAM1aU2aaQkbzh98/gj gZD5GOhpTASrv0ubMHvy4Kk8BWSo7bq7AALEE= MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Wed, 21 Dec 2011 10:51:37 -0700 Subject: Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. To: Joshua Landau Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list 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: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324489930 news.xs4all.nl 6858 [2001:888:2000:d::a6]:44137 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17681 On Wed, Dec 21, 2011 at 9:48 AM, Joshua Landau wrote: > functions, that before you were doing on a single item. > BEFORE: > item =3D foreignfunc1(item) > item =3D foreignfunc2(item) > item =3D foreignfunc3(item) > > NOW (your method): > item =3D ElementwiseProxy(item) > item =3D foreignfunc1(item) > item =3D foreignfunc2(item) > item =3D foreignfunc3(item) > item =3D list(item) Shouldn't that be: item =3D ElementwiseProxy(item) item =3D item.apply(foreignfunc1) item =3D item.apply(foreignfunc2) item =3D item.apply(foreignfunc3) item =3D list(item) > You might think your method works. But what if foreignfunc is "str"? And = you > can't blacklist functions.=A0You can't say everything works bar A, B and = C. > What if you get: "lambda x:str(x)"? You can't blacklist that. That makes = the > ElementwiseProxy version buggy and prone to unstable operation. If it's > consistent, fine. But it's not. I'm not sure I understand this criticism. There is no "blacklisting" going on that I am aware of. The behavior seems consistent to me: Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from elementwise import * >>> ewp =3D ElementwiseProxy(range(5)) >>> str(ewp) '0, 1, 2, 3, 4' >>> (lambda x: str(x))(ewp) '0, 1, 2, 3, 4' >>> ewp.apply(str) '0', '1', '2', '3', '4' >>> ewp.apply(lambda x: str(x)) '0', '1', '2', '3', '4' All of which is exactly what I expected to get. Cheers, Ian