Re:PyPy gets funding from Mozilla for Python 3.5 support
by icebraining on Wednesday August 10, 2016 @02:06AM
(#12259794)
Your example translated to Python is also lazily generated (it uses the lazy equivalent of list comprehensions, called generator expressions):
To me, the examples seem fairly equivalent, with the exception that Python's is, in my opinion, more readable for a newbie, since it doesn't require knowing map() or grep() - just for loops and ifs.
[ Parent
| on HN ]
Re:PyPy gets funding from Mozilla for Python 3.5 support
by kbenson on Wednesday August 10, 2016 @03:36AM
(#12260080)
I was aware of generators in python, but I wasn't aware of the lazy lest comprehensions, which is very nice.
I agree list comprehensions in the simple form are easier for a newbie to recognize, but I also like the way map and filter make you think about your actions, and think they are clearer in the less trivial cases (as I mentioned above). I say "filter" because while I am completely familiar with that terminology, I accept that it's an unneeded departure from the common terminology for that task.
Re:PyPy gets funding from Mozilla for Python 3.5 support
by icebraining on Wednesday August 10, 2016 @04:16AM
(#12260231)
Well, map and filter may be more clear in certain cases, but I still don't see how they are more powerful. Seems like you can do a 1-for-1 translation between the two.
Re:PyPy gets funding from Mozilla for Python 3.5 support
by kbenson on Wednesday August 10, 2016 @10:19AM
(#12261916)
Oh, that's because you must have missed a few comments back where I agreed with you and backed out on any claim they were strictly more powerful. ;)
Re:PyPy gets funding from Mozilla for Python 3.5 support
by icebraining on Wednesday August 10, 2016 @10:48AM
(#12262156)
Ah, uh, sorry ;)