[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>google style guide bans map, reduce, and filter functions

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 22
Thread images: 6

File: 1491212354819.jpg (19KB, 288x240px) Image search: [Google]
1491212354819.jpg
19KB, 288x240px
>google style guide bans map, reduce, and filter functions
You told me functional programming was the next big thing /g/.
>>
File: guido van rossum.jpg (50KB, 333x500px) Image search: [Google]
guido van rossum.jpg
50KB, 333x500px
I see no such prohibition in their C++ style guide.
Their Python style guide was written by this colossal stroopwafel-munching faggot and they haven't bothered changing it since he left.
>>
everyone at google is a brainlet
>>
>>61809824
You're fucking retarded there is no reason to use those functions in Python when list comprehensions are much more readable.
>>
File: 1476836294805.png (30KB, 221x228px) Image search: [Google]
1476836294805.png
30KB, 221x228px
>>61810007
>reduce
>list comprehension
>>
>>61810018
Reduce is a shitty unreadable mess.
>>
>>61810018
with reduce you're supposed to use the for i in iterable construct
>>61809726
i'm assuming this is for python like the other guy and yeah, guido discourages those functions. why are you trying to code golf while using python anyways? it's not a functional language
>>
File: 1484478451795.png (334KB, 430x579px) Image search: [Google]
1484478451795.png
334KB, 430x579px
>>61810039
>using basic functional features
>code golf
>>
File: 1484245635971.png (227KB, 500x500px) Image search: [Google]
1484245635971.png
227KB, 500x500px
>doesn't allow more than one loop in a list comprehension
>>
>>61810067
>smug anime girl
>using badly implemented high order functions in python because you're to intelligent to use haskell
>>
>>61810100
Map is faster and more readable than a list comprehension in some cases.
>>
>>61810144
in python? care to write a code snippet where that's the case and screenshot the times? because i don't believe you.
>>
>>61810144
Fucking prove either of those claims
>>
File: timeit.png (19KB, 622x94px) Image search: [Google]
timeit.png
19KB, 622x94px
>>61810151
>>61810161
>>
>>61810258
>range
Brainlet discovered. range has been deprecated for a while.
>>
>>61810274
>>61810258
Ok I guess I stand corrected. I checked this for python3 (to address your range point), and I even did list(map(str, range(100))) to make sure it wasn't just making a lazy iterator, and I got ~25usec vs ~19usec.
>>
>>61810274
Still faster using xrange.
>>61810306
In 3 map is lazy but it's faster than corresponding gen exp.
>>
>>61810306
map is optimised in cpython to only load the function once, the comprehension has to load the str function from globals every iteration since you could modify it during iteration
>>
>>61810373
>since you could modify it during iteration
When would this happen?
>>
>>61810495
def f(x):
global str
def str(*_, **__):
print("fuck")
return X

[str(f(i)) for i in range(10)]
>>
>>61810576
damn global keyword
>>
>>61810591
The same could happen if you called a class method that modified that method when called
Thread posts: 22
Thread images: 6


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.