Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17681 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2011-12-21 10:51 -0700 |
| Last post | 2011-12-21 10:51 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| 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. |
| Message-ID | <mailman.3932.1324489930.27778.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web