Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17681
| References | (1 earlier) <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 | 2011-12-21 10:51 -0700 |
| Subject | Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3932.1324489930.27778.python-list@python.org> (permalink) |
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
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