{"id":8866,"date":"2021-10-31T21:33:31","date_gmt":"2021-10-31T20:33:31","guid":{"rendered":"https:\/\/monodes.com\/predaelli\/?p=8866"},"modified":"2021-10-31T21:33:31","modified_gmt":"2021-10-31T20:33:31","slug":"write-clean-python-code-using-pipes","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2021\/10\/31\/write-clean-python-code-using-pipes\/","title":{"rendered":"Write Clean Python Code Using Pipes"},"content":{"rendered":"<blockquote>\n<h1><em><a href=\"https:\/\/towardsdatascience.com\/write-clean-python-code-using-pipes-1239a0f3abf5\">Write Clean Python Code Using Pipes<\/a><\/em><\/h1>\n<p>A Short and Clean Approach to Processing Iterables<\/p><\/blockquote>\n<p>Now that&#8217;s an interesting way of coding!<\/p>\n<p><!--more--><!--nextpage--><\/p>\n<blockquote>\n<div class=\"\">\n<h1 id=\"7d18\" class=\"gh gi gj bf gk gl gm gn go gp gq gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg\" data-selectable-paragraph=\"\">Pipes<\/h1>\n<\/div>\n<div class=\"\">\n<h2 id=\"6e2d\" class=\"hh gi gj bf b hi hj hk hl hm hn ho hp hq hr hs ht hu hv hw hx dx\" data-selectable-paragraph=\"\">A Short and Clean Approach to Processing Iterables<\/h2>\n<div class=\"db\">\n<div class=\"n cp hy hz ia\">\n<div class=\"o n\">\n<div>\n<div class=\"at ib ic\">\n<div class=\"id n bc o p ei ie if ig ih ii gb\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div>\n<div class=\"at ib ic\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"s ij ic ib\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/2tiQVZEZxHMPcnVmEmN7UtA.jpeg?resize=28%2C28&#038;ssl=1\" alt=\"Khuyen Tran\" width=\"28\" height=\"28\" \/><\/div>\n<\/div>\n<div class=\"ik v n cy\">\n<div class=\"n\">\n<div>\n<div>\n<div class=\"ca\" role=\"tooltip\" aria-hidden=\"false\" aria-describedby=\"22\" aria-labelledby=\"22\">\n<p class=\"bf b bg bh fd\">Khuyen Tran<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"bf b bg bh dx\">4 days ago<span class=\"ip\">\u00b7<\/span>5 min read<\/p>\n<\/div>\n<div class=\"n o\">\n<div class=\"oq s z\"><\/div>\n<\/div>\n<div class=\"oq s z\"><\/div>\n<div class=\"oq s z\"><\/div>\n<div class=\"s z\"><\/div>\n<div class=\"iz s\"><\/div>\n<section class=\"gc gd ge du gf\">\n<div class=\"n p\">\n<div class=\"au av aw ax ay gg ba v\">\n<div class=\"\">\n<div class=\"db\">\n<div class=\"n cp hy hz ia\">\n<div class=\"n iq ir is it iu iv iw ix iy\">\n<div class=\"n o\">\n<div class=\"s bd\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h1 id=\"5076\" class=\"ja jb gj bf jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx hg\" data-selectable-paragraph=\"\">Motivation<\/h1>\n<p id=\"a5b2\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\"><code class=\"\" data-line=\"\">map<\/code> and <code class=\"\" data-line=\"\">filter<\/code> are two efficient Python methods to work with iterables. However, the code can look messy if you use both <code class=\"\" data-line=\"\">map<\/code> and <code class=\"\" data-line=\"\">filter<\/code> at the same time.<\/p>\n<\/div>\n<\/div>\n<div class=\"kx\">\n<div class=\"n p\">\n<div class=\"ky kz la lb lc ld ax le ay lf ba v\">\n<figure class=\"lh li lj lk ll kx lm ln paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq lg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"v ls lt\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/18D5THbKGu368fgqNXvUAqQ.png?resize=910%2C359&#038;ssl=1\" alt=\"\" width=\"910\" height=\"359\" \/><\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"n p\">\n<div class=\"au av aw ax ay gg ba v\">\n<p id=\"8f54\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Wouldn\u2019t be nice if you can use pipes <code class=\"\" data-line=\"\">|<\/code> to apply multiple methods on an iterable like below?<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq pe\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"v ls lt\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1tUI5sEgmgQ5lhTQOYu9hQg.png?resize=700%2C495&#038;ssl=1\" alt=\"\" width=\"700\" height=\"495\" \/><\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<p id=\"3d0a\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">The library Pipe allows you to do exactly that.<\/p>\n<h1 id=\"5b0f\" class=\"ja jb gj bf jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx hg\" data-selectable-paragraph=\"\">What is Pipe?<\/h1>\n<p id=\"5ace\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\"><mark class=\"zs zt en\"><a class=\"ea oe\" href=\"https:\/\/github.com\/JulienPalard\/Pipe\" target=\"_blank\" rel=\"noopener ugc nofollow\">Pipe<\/a><\/mark><mark class=\"zs zt en\"> is a Python library that enables you to use pipes in Python. A pipe (<\/mark><mark class=\"zs zt en\"><code class=\"\" data-line=\"\">|<\/code><\/mark><mark class=\"zs zt en\">) passes the results of one method to another method.<\/mark><\/p>\n<p id=\"8be7\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">I like Pipe because<span id=\"rmm\"> <\/span>it makes my code look cleaner when applying multiple methods to a Python iterable. Since Pipe only provides a few methods, it is also very easy to learn Pipe. In this article, I will show you some methods I found the most useful.<\/p>\n<p id=\"ba13\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">To install Pipe, type:<\/p>\n<pre class=\"lh li lj lk ll pf pg ph\"><span id=\"2a42\" class=\"hg pi jb gj kw b dn pj pk s pl\" data-selectable-paragraph=\"\">pip install pipe<\/span><\/pre>\n<h1 id=\"30fe\" class=\"ja jb gj bf jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx hg\" data-selectable-paragraph=\"\">Where \u2014 Filter Elements in an Iterable<\/h1>\n<p id=\"8cf4\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\">Similar to SQL, Pipe\u2019s <code class=\"\" data-line=\"\">where<\/code> method can also be used to filter elements in an iterable.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq pe\">\n<div class=\"pp s at ks\">\n<div class=\"pq pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1RKIzK9VpkoVrTgnXBnecWw.png?resize=700%2C446&#038;ssl=1\" alt=\"\" width=\"700\" height=\"446\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1RKIzK9VpkoVrTgnXBnecWw-1.png?resize=700%2C446&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*RKIzK9VpkoVrTgnXBnecWw.png 276w, https:\/\/miro.medium.com\/max\/552\/1*RKIzK9VpkoVrTgnXBnecWw.png 552w, https:\/\/miro.medium.com\/max\/640\/1*RKIzK9VpkoVrTgnXBnecWw.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1RKIzK9VpkoVrTgnXBnecWw-1.png 700w\" alt=\"\" width=\"700\" height=\"446\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<h1 id=\"9f5b\" class=\"ja jb gj bf jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx hg\" data-selectable-paragraph=\"\">Select \u2014 Apply a Function to an Iterable<\/h1>\n<p id=\"6b61\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\">The <code class=\"\" data-line=\"\">select<\/code> method is similar to the <code class=\"\" data-line=\"\">map<\/code> method. <code class=\"\" data-line=\"\">select<\/code> applies a method to each element of an iterable.<\/p>\n<p id=\"9a8f\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">In the code below, I use <code class=\"\" data-line=\"\">select<\/code> to multiply each element in the list by 2.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq pe\">\n<div class=\"pp s at ks\">\n<div class=\"pq pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1yxLCiXEKmyspWMMdhQ_bgQ.png?resize=700%2C446&#038;ssl=1\" alt=\"\" width=\"700\" height=\"446\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1yxLCiXEKmyspWMMdhQ_bgQ-1.png?resize=700%2C446&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*yxLCiXEKmyspWMMdhQ_bgQ.png 276w, https:\/\/miro.medium.com\/max\/552\/1*yxLCiXEKmyspWMMdhQ_bgQ.png 552w, https:\/\/miro.medium.com\/max\/640\/1*yxLCiXEKmyspWMMdhQ_bgQ.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1yxLCiXEKmyspWMMdhQ_bgQ-1.png 700w\" alt=\"\" width=\"700\" height=\"446\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<p id=\"0028\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Now, you might wonder: Why do we need the methods <code class=\"\" data-line=\"\">where<\/code> and <code class=\"\" data-line=\"\">select<\/code> if they have the same functionalities as <code class=\"\" data-line=\"\">map<\/code> and <code class=\"\" data-line=\"\">filter<\/code> ?<\/p>\n<p id=\"3280\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">It is because you can insert one method after another method using pipes. As a result, using pipes removes nested parentheses and makes the code more readable.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq pe\">\n<div class=\"pp s at ks\">\n<div class=\"pu pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1tUI5sEgmgQ5lhTQOYu9hQg-1.png?resize=700%2C495&#038;ssl=1\" alt=\"\" width=\"700\" height=\"495\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1tUI5sEgmgQ5lhTQOYu9hQg-2.png?resize=700%2C495&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*tUI5sEgmgQ5lhTQOYu9hQg.png 276w, https:\/\/miro.medium.com\/max\/552\/1*tUI5sEgmgQ5lhTQOYu9hQg.png 552w, https:\/\/miro.medium.com\/max\/640\/1*tUI5sEgmgQ5lhTQOYu9hQg.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1tUI5sEgmgQ5lhTQOYu9hQg-2.png 700w\" alt=\"\" width=\"700\" height=\"495\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<h1 id=\"5bed\" class=\"ja jb gj bf jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx hg\" data-selectable-paragraph=\"\">Unfold Iterables<\/h1>\n<h2 id=\"4050\" class=\"pi jb gj bf jc pv pw hk jg px py hn jk ho pz hq jo hr qa ht js hu qb hw jw qc hg\" data-selectable-paragraph=\"\">chain \u2014 Chain a Sequence of Iterables<\/h2>\n<p id=\"78e9\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\">It can be a pain to work with a nested iterable. Luckily, you can use <code class=\"\" data-line=\"\">chain<\/code> to chain a sequence of iterables.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq qd\">\n<div class=\"pp s at ks\">\n<div class=\"qe pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/12QjM4mSlQciSPrc9U0D9AQ.png?resize=700%2C497&#038;ssl=1\" alt=\"\" width=\"700\" height=\"497\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/12QjM4mSlQciSPrc9U0D9AQ-1.png?resize=700%2C497&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*2QjM4mSlQciSPrc9U0D9AQ.png 276w, https:\/\/miro.medium.com\/max\/552\/1*2QjM4mSlQciSPrc9U0D9AQ.png 552w, https:\/\/miro.medium.com\/max\/640\/1*2QjM4mSlQciSPrc9U0D9AQ.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/12QjM4mSlQciSPrc9U0D9AQ-1.png 700w\" alt=\"\" width=\"700\" height=\"497\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<p id=\"dec3\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Even though the iterable is less nested after applying <code class=\"\" data-line=\"\">chain<\/code>, we still have a nested list. To deal with a deeply nested list, we can use <code class=\"\" data-line=\"\">traverse<\/code> instead.<\/p>\n<h2 id=\"3022\" class=\"pi jb gj bf jc pv pw hk jg px py hn jk ho pz hq jo hr qa ht js hu qb hw jw qc hg\" data-selectable-paragraph=\"\">traverse \u2014 Recursively Unfold Iterables<\/h2>\n<p id=\"b58b\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\">The <code class=\"\" data-line=\"\">traverse<\/code> method can be used to recursively unfold iterables. Thus, you can use this method to turn a deeply nested list into a flat list.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq qd\">\n<div class=\"pp s at ks\">\n<div class=\"qe pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1IgQ736NVc6f_TfRTfF3m_w.png?resize=700%2C497&#038;ssl=1\" alt=\"\" width=\"700\" height=\"497\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1IgQ736NVc6f_TfRTfF3m_w-1.png?resize=700%2C497&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*IgQ736NVc6f_TfRTfF3m_w.png 276w, https:\/\/miro.medium.com\/max\/552\/1*IgQ736NVc6f_TfRTfF3m_w.png 552w, https:\/\/miro.medium.com\/max\/640\/1*IgQ736NVc6f_TfRTfF3m_w.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1IgQ736NVc6f_TfRTfF3m_w-1.png 700w\" alt=\"\" width=\"700\" height=\"497\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<p id=\"f0b0\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Let\u2019s integrate this method with the <code class=\"\" data-line=\"\">select<\/code> method to get the values of a dictionary and flatten the list.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq qf\">\n<div class=\"pp s at ks\">\n<div class=\"qg pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/101vApchQJQjewbR3w0-O0w.png?resize=700%2C526&#038;ssl=1\" alt=\"\" width=\"700\" height=\"526\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/101vApchQJQjewbR3w0-O0w-1.png?resize=700%2C526&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*01vApchQJQjewbR3w0-O0w.png 276w, https:\/\/miro.medium.com\/max\/552\/1*01vApchQJQjewbR3w0-O0w.png 552w, https:\/\/miro.medium.com\/max\/640\/1*01vApchQJQjewbR3w0-O0w.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/101vApchQJQjewbR3w0-O0w-1.png 700w\" alt=\"\" width=\"700\" height=\"526\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<p id=\"a328\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Pretty cool!<\/p>\n<h1 id=\"6f98\" class=\"ja jb gj bf jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx hg\" data-selectable-paragraph=\"\">Group Elements in a List<\/h1>\n<p id=\"2e19\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\">Sometimes, it might be useful to group elements in a list using a certain function. That could be easily done with the <code class=\"\" data-line=\"\">groupby<\/code> method.<\/p>\n<p id=\"2f4f\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">To see how this method works, let\u2019s turn a list of numbers into a dictionary that groups numbers based on whether they are even or odd.<\/p>\n<\/div>\n<\/div>\n<div class=\"kx\">\n<div class=\"n p\">\n<div class=\"ky kz la lb lc ld ax le ay lf ba v\">\n<figure class=\"lh li lj lk ll kx lm ln paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq qh\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"v ls lt\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1rh2vSxQZrn7exvB0v4Z59g.png?resize=910%2C541&#038;ssl=1\" alt=\"\" width=\"910\" height=\"541\" \/><\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"n p\">\n<div class=\"au av aw ax ay gg ba v\">\n<p id=\"8d13\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">In the code above, we use <code class=\"\" data-line=\"\">groupby<\/code> to group numbers into the<code class=\"\" data-line=\"\">Even<\/code> group and the<code class=\"\" data-line=\"\">Odd<\/code> group. The output after applying this method looks like the below:<\/p>\n<pre class=\"lh li lj lk ll pf pg ph\"><span id=\"f87b\" class=\"hg pi jb gj kw b dn pj pk s pl\" data-selectable-paragraph=\"\">[('Even', &lt;itertools._grouper at 0x7fbea8030550&gt;),\n ('Odd', &lt;itertools._grouper at 0x7fbea80309a0&gt;)]<\/span><\/pre>\n<p id=\"c1d3\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Next, we use <code class=\"\" data-line=\"\">select<\/code> to turn a list of tuples into a list of dictionaries whose keys are the first elements in the tuples and values are the second elements in the tuples.<\/p>\n<pre class=\"lh li lj lk ll pf pg ph\"><span id=\"2cc5\" class=\"hg pi jb gj kw b dn pj pk s pl\" data-selectable-paragraph=\"\">[{'Even': [2, 4, 6, 8]}, {'Odd': [1, 3, 5, 7, 9]}]<\/span><\/pre>\n<p id=\"57c7\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Cool! To get only the values that are greater than 2, we can add the <code class=\"\" data-line=\"\">where<\/code> method inside the <code class=\"\" data-line=\"\">select<\/code> method:<\/p>\n<\/div>\n<\/div>\n<div class=\"kx\">\n<div class=\"n p\">\n<div class=\"ky kz la lb lc ld ax le ay lf ba v\">\n<figure class=\"lh li lj lk ll kx lm ln paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq qi\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"v ls lt\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/10reeJdg9AHUx1uyknE_66g.png?resize=910%2C457&#038;ssl=1\" alt=\"\" width=\"910\" height=\"457\" \/><\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"n p\">\n<div class=\"au av aw ax ay gg ba v\">\n<p id=\"bf74\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Note that there are no longer <code class=\"\" data-line=\"\">2<\/code> and <code class=\"\" data-line=\"\">1<\/code> in the outputs.<\/p>\n<h1 id=\"719c\" class=\"ja jb gj bf jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx hg\" data-selectable-paragraph=\"\">dedup \u2014 Deduplicate Values Using a Key<\/h1>\n<p id=\"ef25\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\">The <code class=\"\" data-line=\"\">dedup<\/code> method removes duplicates in a list.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq qj\">\n<div class=\"pp s at ks\">\n<div class=\"qk pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1aBYXrm_7w68anKcWEAjm7w.png?resize=700%2C386&#038;ssl=1\" alt=\"\" width=\"700\" height=\"386\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1aBYXrm_7w68anKcWEAjm7w-1.png?resize=700%2C386&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*aBYXrm_7w68anKcWEAjm7w.png 276w, https:\/\/miro.medium.com\/max\/552\/1*aBYXrm_7w68anKcWEAjm7w.png 552w, https:\/\/miro.medium.com\/max\/640\/1*aBYXrm_7w68anKcWEAjm7w.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1aBYXrm_7w68anKcWEAjm7w-1.png 700w\" alt=\"\" width=\"700\" height=\"386\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<p id=\"dabb\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">That might not sound interesting since the <code class=\"\" data-line=\"\">set<\/code> method can do the same thing. However, this method is more flexible since it enables you to get unique elements using a key.<\/p>\n<p id=\"2118\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">For example, you can use this method to get a unique element that is smaller than 5 and another unique element that is larger than or equal to 5.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq qj\">\n<div class=\"pp s at ks\">\n<div class=\"qk pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1RKnjElOWmA06_ftSmMYmWQ.png?resize=700%2C386&#038;ssl=1\" alt=\"\" width=\"700\" height=\"386\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1RKnjElOWmA06_ftSmMYmWQ-1.png?resize=700%2C386&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*RKnjElOWmA06_ftSmMYmWQ.png 276w, https:\/\/miro.medium.com\/max\/552\/1*RKnjElOWmA06_ftSmMYmWQ.png 552w, https:\/\/miro.medium.com\/max\/640\/1*RKnjElOWmA06_ftSmMYmWQ.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1RKnjElOWmA06_ftSmMYmWQ-1.png 700w\" alt=\"\" width=\"700\" height=\"386\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<p id=\"57f9\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Now, let\u2019s combine this method with <code class=\"\" data-line=\"\">select<\/code> and <code class=\"\" data-line=\"\">where<\/code> to get the values of a dictionary that has duplicated keys and <code class=\"\" data-line=\"\">None<\/code> values.<\/p>\n<figure class=\"lh li lj lk ll kx fp fq paragraph-image\">\n<div class=\"lo lp at lq v lr\" tabindex=\"0\" role=\"button\">\n<div class=\"fp fq ql\">\n<div class=\"pp s at ks\">\n<div class=\"qm pr s\">\n<div class=\"es pm ei ev er fa v pb pn po\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"ei ev er fa v ps pt ae abz\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1X1eRTaS8h0nv9SeXIKYPPQ.png?resize=700%2C603&#038;ssl=1\" alt=\"\" width=\"700\" height=\"603\" \/><\/div>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"mt yn ei ev er fa v c\" role=\"presentation\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1X1eRTaS8h0nv9SeXIKYPPQ-1.png?resize=700%2C603&#038;ssl=1\" sizes=\"auto, 700px\" srcset=\"https:\/\/miro.medium.com\/max\/276\/1*X1eRTaS8h0nv9SeXIKYPPQ.png 276w, https:\/\/miro.medium.com\/max\/552\/1*X1eRTaS8h0nv9SeXIKYPPQ.png 552w, https:\/\/miro.medium.com\/max\/640\/1*X1eRTaS8h0nv9SeXIKYPPQ.png 640w, https:\/\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/10\/1X1eRTaS8h0nv9SeXIKYPPQ-1.png 700w\" alt=\"\" width=\"700\" height=\"603\" \/><\/div>\n<\/div>\n<\/div>\n<\/div><figcaption class=\"lu lv fr fp fq lw lx bf b bg bh dx\" data-selectable-paragraph=\"\">Image by Author<\/figcaption><\/figure>\n<p id=\"d666\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">In the code above, we:<\/p>\n<ul class=\"\">\n<li id=\"49af\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr qn qo qp hg\" data-selectable-paragraph=\"\">remove items with the same <code class=\"\" data-line=\"\">name<\/code><\/li>\n<li id=\"6e07\" class=\"jy jz gj ka b hi qq jf kc hl qr jj ke kf qs kh ki kj qt kl km kn qu kp kq kr qn qo qp hg\" data-selectable-paragraph=\"\">get the values of <code class=\"\" data-line=\"\">count<\/code><\/li>\n<li id=\"ebfb\" class=\"jy jz gj ka b hi qq jf kc hl qr jj ke kf qs kh ki kj qt kl km kn qu kp kq kr qn qo qp hg\" data-selectable-paragraph=\"\">only choose the values that are integers.<\/li>\n<\/ul>\n<p id=\"1fe5\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Within a few lines of code, we can apply multiple methods to an iterable while still keeping the code clean. Pretty cool, isn\u2019t it?<\/p>\n<h1 id=\"7026\" class=\"ja jb gj bf jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx hg\" data-selectable-paragraph=\"\">Conclusion<\/h1>\n<p id=\"4d76\" class=\"jy jz gj ka b hi kb jf kc hl kd jj ke kf kg kh ki kj kk kl km kn ko kp kq kr gc hg\" data-selectable-paragraph=\"\">Congratulations! You have just learned how to use pipe to keep your code clean and short. I hope this article will give you the knowledge to turn complicated operations on an iterable into one simple line of code.<\/p>\n<p id=\"dee0\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Feel free to play and fork the source code of this article here:<\/p>\n<div class=\"qv qw qx qy qz ra\">\n<div class=\"em n z\">\n<div class=\"rb n ao p rc rd\">\n<h2 class=\"bf gk dn bh pb re rf rg rh ri rj gi hg\">Data-science\/pipe.ipynb at master \u00b7 khuyentran1401\/Data-science<\/h2>\n<div class=\"rk s\">\n<h3 class=\"bf b dn bh pb re rf rg rh ri rj dx\">Collection of useful data science topics along with code and articles &#8211; Data-science\/pipe.ipynb at master \u00b7\u2026<\/h3>\n<\/div>\n<div class=\"rl s\">\n<p class=\"bf b ny bh pb re rf rg rh ri rj dx\">github.com<\/p>\n<\/div>\n<\/div>\n<div class=\"rm s\">\n<div class=\"rn s ro rp rq rm rr ls ra\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/section>\n<div class=\"n p db rs rt ru\" role=\"separator\"><\/div>\n<section class=\"gc gd ge du gf\">\n<div class=\"n p\">\n<div class=\"au av aw ax ay gg ba v\">\n<p id=\"4f04\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">I like to write about basic data science concepts and play with different algorithms and data science tools. You could connect with me on <a class=\"ea oe\" href=\"https:\/\/www.linkedin.com\/in\/khuyen-tran-1401\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">LinkedIn<\/a> and <a class=\"ea oe\" href=\"https:\/\/twitter.com\/KhuyenTran16\" target=\"_blank\" rel=\"noopener ugc nofollow\">Twitter<\/a>.<\/p>\n<p id=\"f7b3\" class=\"jy jz gj ka b hi ly jf kc hl lz jj ke kf ma kh ki kj mb kl km kn mc kp kq kr gc hg\" data-selectable-paragraph=\"\">Star <a class=\"ea oe\" href=\"https:\/\/github.com\/khuyentran1401\/Data-science\" target=\"_blank\" rel=\"noopener ugc nofollow\">this repo<\/a> if you want to check out the codes for all of the articles I have written. Follow me on Medium to stay informed with my latest data science articles like these:<\/p>\n<\/div>\n<\/div>\n<\/section>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Write Clean Python Code Using Pipes A Short and Clean Approach to Processing Iterables Now that&#8217;s an interesting way of coding!<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2021\/10\/31\/write-clean-python-code-using-pipes\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"link","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[113],"tags":[],"class_list":["post-8866","post","type-post","status-publish","format-link","hentry","category-python","post_format-post-format-link"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-2j0","jetpack-related-posts":[{"id":9532,"url":"https:\/\/monodes.com\/predaelli\/2022\/08\/09\/7-python-one-liners-that-will-blow-your-mind\/","url_meta":{"origin":8866,"position":0},"title":"7 Python One-Liners that will Blow Your Mind","author":"Paolo Redaelli","date":"2022-08-09","format":false,"excerpt":"Xiaoxu Gao wrote 7 Python One-Liners that will Blow Your Mind Less is more? Photo by Photos by Lanty from Unsplash The term one-liner comes from comedy where a joke is delivered in a single line. A good one-liner is said to be meaningful and concise. This concept also exists\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/monodes.com\/predaelli\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10691,"url":"https:\/\/monodes.com\/predaelli\/2023\/08\/13\/noob-or-just-oldish\/","url_meta":{"origin":8866,"position":1},"title":"Noob or &#8220;just&#8221; oldish?","author":"Paolo Redaelli","date":"2023-08-13","format":false,"excerpt":"Young Jedi Anmol Tomar, your pythoninc knowledge lacks historical viewpoint. List Comprehensions were the Python Enhancement Proposals( PEP) 202. In fact Anmol Tomar wrote on medium.com \"9 Python Mistakes That Reveal You\u2019re a Nooby! Move away from noob status!\". Too bad he want to be read only by people in\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/monodes.com\/predaelli\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6318,"url":"https:\/\/monodes.com\/predaelli\/2019\/12\/15\/eiffels-conditional-expressions\/","url_meta":{"origin":8866,"position":2},"title":"Eiffel&#8217;s conditional expressions","author":"Paolo Redaelli","date":"2019-12-15","format":false,"excerpt":"The ternary conditional operator is a short-hand method for writing an if\/else statement. Does Python Have a Ternary Conditional Operator? Yes, it does. This remids me that Eiffel, at least \"ISE Eiffel\" does actually have conditional expressions that are the same: answer := if time < noon then \"Good morning\"\u2026","rel":"","context":"In &quot;Eiffel&quot;","block_context":{"text":"Eiffel","link":"https:\/\/monodes.com\/predaelli\/category\/eiffel\/"},"img":{"alt_text":"Jonathan Hsu","src":"https:\/\/i0.wp.com\/miro.medium.com\/fit\/c\/58\/58\/2%2A_KGzadiy9s83D4vzhsCyyg.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":9066,"url":"https:\/\/monodes.com\/predaelli\/2022\/01\/14\/getting-started-with-cython-how-to-perform-1-7-billion-calculations-per-second-in-python\/","url_meta":{"origin":8866,"position":3},"title":"Getting started with Cython: How to perform >1.7 billion calculations per second in Python","author":"Paolo Redaelli","date":"2022-01-14","format":false,"excerpt":"Getting started with Cython: How to perform >1.7 billion calculations per second in Python Combine the ease of Python with the speed of C Mike HulsDec 8, 2021\u00b711 min read Cython will add an afterburner to your program (image by Oscar Sutton on Unsplash) The main advantage of Python is\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/monodes.com\/predaelli\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8787,"url":"https:\/\/monodes.com\/predaelli\/2021\/10\/12\/write-better-and-faster-python-using-einstein-notation-by-bilal-himite-aug-2021-towards-data-science\/","url_meta":{"origin":8866,"position":4},"title":"Write Better And Faster Python Using Einstein Notation | by Bilal Himite | Aug, 2021 | Towards Data Science","author":"Paolo Redaelli","date":"2021-10-12","format":false,"excerpt":"How to make your code more readable, concise, and efficient using Einstein notation Source: Write Better And Faster Python Using Einstein Notation | by Bilal Himite | Aug, 2021 | Towards Data Science","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/monodes.com\/predaelli\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4792,"url":"https:\/\/monodes.com\/predaelli\/2018\/10\/28\/telosys-code-generator-for-java-javascript-python-nodejs-php-c-etc\/","url_meta":{"origin":8866,"position":5},"title":"Telosys code generator for Java, JavaScript, Python, NodeJS, PHP, C#, etc","author":"Paolo Redaelli","date":"2018-10-28","format":false,"excerpt":"Telosys is a free code generator usable with different languages or frameworks : Java, JavaScript, Python, NodeJS, PHP, GoLang, C#, Angular, VueJS, etc Sorgente: Telosys code generator for Java, JavaScript, Python, NodeJS, PHP, C#, etc","rel":"","context":"In &quot;Senza categoria&quot;","block_context":{"text":"Senza categoria","link":"https:\/\/monodes.com\/predaelli\/category\/senza-categoria\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/8866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=8866"}],"version-history":[{"count":0,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/8866\/revisions"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=8866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=8866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=8866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}