Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python,': 0.01; 'debug': 0.03; 'numerical': 0.05; 'disagree': 0.07; 'expressions.': 0.09; 'readable': 0.09; 'subject:method': 0.09; 'list?': 0.13; 'intermediate': 0.15; '*always*': 0.16; 'int(x)': 0.16; 'iterator': 0.16; 'subject:function': 0.16; 'subject:python.': 0.16; 'subject:release': 0.16; '\xa0as': 0.16; 'syntax': 0.16; 'examples': 0.16; 'wrote:': 0.18; 'converted': 0.18; 'functions,': 0.18; 'dec': 0.22; '(or': 0.22; 'header:In-Reply-To:1': 0.22; 'statement': 0.23; 'thus': 0.23; 'though.': 0.23; '\xa0if': 0.23; 'object,': 0.24; 'expect': 0.26; 'raise': 0.28; 'work.': 0.28; 'message-id:@mail.gmail.com': 0.28; 'pass': 0.29; 'pm,': 0.29; 'correct': 0.29; 'lines': 0.30; 'collections': 0.30; 'comments.': 0.30; 'kelly': 0.30; 'nature.': 0.30; 'received:209.85.210.46': 0.30; 'received:mail-pz0-f46.google.com': 0.30; 'subject:support': 0.30; 'skip:( 20': 0.31; 'values': 0.32; 'tue,': 0.32; 'idea': 0.32; "can't": 0.32; 'there': 0.33; 'to:addr:python-list': 0.34; 'things': 0.34; 'anything': 0.34; 'something': 0.35; 'expanding': 0.35; 'regular': 0.35; 'element': 0.37; 'instead,': 0.37; 'to:name :python-list': 0.37; 'skip:" 10': 0.37; 'list,': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'role': 0.37; 'could': 0.37; 'some': 0.38; 'hoping': 0.38; 'received:209.85': 0.38; 'should': 0.39; 'subject: (': 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'might': 0.40; 'hope': 0.61; 'more': 0.61; 'type': 0.61; '2011': 0.61; 'matter': 0.61; 'your': 0.61; 'back': 0.62; 'refuse': 0.67; 'collection': 0.69; 'concept': 0.74; '12:45': 0.84; 'nathan': 0.84; 'respectively': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=fMcfP6TX/ahL0R36n2Acj1qZIjD648ILMqNb3tVUJE4=; b=iRefXAaZglc6bp6mkSQklGg0QEiRdUeJk3/b2UuXfq7zxbejFlFRua0QcD221h9ABd SdEkLJndzezapG8pMdKImHwrD4PWJIzl4Hu0KRs1FRV6rO3oHn0pIocOpzRyx99IA//n 7X6/umPzZlDflSvolF5i/47S3d8J52+IZFdEo= MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 20 Dec 2011 19:24:49 -0500 Subject: Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. From: Nathan Rice To: python-list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324427093 news.xs4all.nl 6961 [2001:888:2000:d::a6]:33636 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17630 On Tue, Dec 20, 2011 at 7:03 PM, Ian Kelly wrote: > On Tue, Dec 20, 2011 at 12:45 PM, Nathan Rice > wrote: >> There are still some issues with proper support of things like bool() >> and int(), which refuse to return things that are not of the correct >> type. > > And that's a good thing. =A0As type conversion functions, bool(x) and > int(x) should *always* return bools and ints respectively (or raise an > exception), no matter what you pass in for x. I was hoping to have the proxy be completely transparent. I don't disagree with your statement though. > If I do "list(efoo)", where efoo is an ElementwiseProxy object, should > I expect to get the efoo collection converted to a list, or another > ElementwiseProxy where each element has been converted to a list? =A0I > would hope the former. Iterators are how you go from an ElementwiseProxy back to a regular collection. Thus list/set/etc or anything that takes an iterator will work. >> This was developed as a proof of concept for expanding the role of >> element-wise syntax in python, and to that end I welcome comments. > > The examples you gave are all numerical in nature. =A0If I might > inquire, what might I use this for that I can't already do with numpy? efoo2 =3D ElementwiseProxy(["one", "two", "three", "four"]) efoo_res =3D ((efoo2.capitalize() + " little indian").split(" ").apply(reversed) * 2).apply("_".join) # note that you could do reversed(...) instead, I just like to read left to right efoo_res.parent.parent.parent # same as ((efoo2.capitalize() + " little indian").split(" ") in case you need to debug something and want to look at intermediate values The idea is to provide a syntax that lets you do very complex things on collections in a more readable manner, without having 5 or 6 lines of generator expressions. Nathan