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


Groups > comp.lang.python > #17681

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.

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 <ian.g.kelly@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; '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 <CAN1F8qXei47p0d6P0WAmEi62M8ftWSbCjdTFvb6FUH_VzCRG1Q@mail.gmail.com>
References <CAOFbRmLyw88pHNSdszQY672ukAcm965jDUamXQGOFXoX9pd3+Q@mail.gmail.com> <CALwzidkOYp8FzfQ-s4wiNHy4TW3R03Cq7qQDSSNV=Zcf1OgQkA@mail.gmail.com> <CAOFbRm+p-aJGz_9FULsz=qOY9Htwd2XVKbS6Y-pc7wwoFfGQ-A@mail.gmail.com> <CAN1F8qXFh458AXq-Ae3V2k1-aFeP=KOG--=nJfrgU4HzF7qyqw@mail.gmail.com> <CAOFbRmLcuG_Aru3cTxNv2iHaRQsAATaS0FFhfvq_OJRnEz0xFA@mail.gmail.com> <CAN1F8qXei47p0d6P0WAmEi62M8ftWSbCjdTFvb6FUH_VzCRG1Q@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
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 <joshua.landau.ws@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc python-list <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 <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.3932.1324489930.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Wed, Dec 21, 2011 at 9:48 AM, Joshua Landau
<joshua.landau.ws@gmail.com> wrote:
> functions, that before you were doing on a single item.
> BEFORE:
> item = foreignfunc1(item)
> item = foreignfunc2(item)
> item = foreignfunc3(item)
>
> NOW (your method):
> item = ElementwiseProxy(item)
> item = foreignfunc1(item)
> item = foreignfunc2(item)
> item = foreignfunc3(item)
> item = list(item)

Shouldn't that be:

item = ElementwiseProxy(item)
item = item.apply(foreignfunc1)
item = item.apply(foreignfunc2)
item = item.apply(foreignfunc3)
item = list(item)

> You might think your method works. But what if foreignfunc is "str"? And you
> can't blacklist functions. You 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 = 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

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


Thread

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-21 10:51 -0700

csiph-web