<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mohit Sarpal on Medium]]></title>
        <description><![CDATA[Stories by Mohit Sarpal on Medium]]></description>
        <link>https://medium.com/@mohitsarpal50?source=rss-92ffeff9abac------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*XsJ4ZCOydMh91SMYqBvamg.jpeg</url>
            <title>Stories by Mohit Sarpal on Medium</title>
            <link>https://medium.com/@mohitsarpal50?source=rss-92ffeff9abac------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:29:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohitsarpal50/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Production Stack — Python]]></title>
            <link>https://medium.com/@mohitsarpal50/production-stack-python-99b5ffef1bf2?source=rss-92ffeff9abac------2</link>
            <guid isPermaLink="false">https://medium.com/p/99b5ffef1bf2</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[production]]></category>
            <category><![CDATA[cython]]></category>
            <category><![CDATA[gunicorn]]></category>
            <dc:creator><![CDATA[Mohit Sarpal]]></dc:creator>
            <pubDate>Sun, 02 Feb 2020 08:45:28 GMT</pubDate>
            <atom:updated>2020-02-02T08:45:28.814Z</atom:updated>
            <content:encoded><![CDATA[<h3>Production Stack — Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*fIVwrwboXJT_GAxEwUALIA.png" /></figure><p>According to the <a href="https://pypl.github.io/PYPL.html"><strong>Popularity of Programming Language Index</strong></a>, Python is the most popular programming language in the world. Youtube uses Python, Netflix uses Python and hundreds of companies. Even dropbox too is created in Python.</p><p>Do you? If yes, this tutorial is going to take your application to the next level.</p><p><strong>Problems with Python:-</strong></p><p><strong>1.GIL: </strong>Global Interpreter Lock</p><p>In simple words, GIL is a lock that allows only one thread to hold control of the Python interpreter.</p><p>Modern software is multithreaded and multicore, and so just about every modern programming language offers <strong>concurrency</strong>. Python ships with a threading module; but due to how the Python interpreter is implemented, it can only ever run <em>one thread at a time due to Global Interpreter Lock</em></p><p><strong>2.Performance</strong></p><p>We often hear the same complaint about Python over and over again, especially from C/C or Go Developers — ” <em>Python is slow”.</em></p><p>And this is true, even <a href="https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/gpp-python3.html?source=post_page---------------------------">Benchmark game</a> has shown very solid benchmarking.</p><p>Python is interpreted language and is slow as compared to C/C++ or Java. Unlike C or C++. In this case, the execution of Python takes place with the help of an interpreter instead of the compiler as we have seen that Python code is executed line by line, which causes it to slow down.</p><p><strong>3.Memory Consumption</strong></p><p>Python is not a good choice for any memory-intensive tasks. That is why it is not used for that purpose.</p><p>Python’s memory consumption is also high, due to the flexibility of the data types. This is one of the main reasons developers use C/C++ or Java for Competitive Coding.</p><p><strong>But don’t worry. The following tools are going to overcome these problems and make your application better.</strong></p><p><strong>1.Gunicorn: </strong>a Production server for Python application</p><p>The <strong>Django</strong> and <strong>Flask</strong> are frameworks, not Servers. These blocking servers only process a single request at a time.</p><p><a href="http://gunicorn.org/">Gunicorn</a> is a pure-Python HTTP server for WSGI applications. It allows you to run any Python application concurrently by running multiple Python processes. It provides a perfect balance of performance, flexibility, and configuration simplicity.</p><p>Even if you set <em>threaded = true</em>, while running a flask server, you will never know the count, how many concurrent requests your application can handle.</p><p>It works only in Linux. <strong>Waitress</strong> is the alternative of Gunicorn for the Windows platform.</p><p><strong>2. Cython</strong></p><p>It allows you to write pure Python code with some minor modifications, which is then translated directly into C code.</p><p>If you, like me, enjoy coding in Python and still want to speed up your code you could consider using <strong>Cython</strong>. While Cython itself is a separate programming language. Upon execution, Cython translates your Python code to C, oftentimes significantly speeding it up.</p><p>Pure Python is indeed quite slow, Python in practice is not. Libraries like Numpy, Pandas, and Scikit-learn all are C Optimized. When you use them, you’re making use of C/C++ power, you’re just able to use Python syntax. Numpy, Pandas, and Scikit-learn all make use of Cython.</p><p><strong>3.Black: </strong>The Uncompromising Code Formatter.</p><p>Code formatting is the subject of millions of fiery debates. Developers love to argue about code style because we read code a lot. The style matters because it affects readability.</p><p>If we drill into the Python example, we can see a difference compared to Go. gofmt is a <em>tool</em> that will automatically fix style errors. PEP 8 is a <em>style guide</em>.</p><p><strong><em>Black</em></strong><em> is like </em><em>gofmt for Python.</em> While it’s not a tool that is officially endorsed by the Python core team, it does automatically format code.</p><p>Black’s formatting rules are a superset of PEP 8. If you choose to use Black, you get PEP 8 compliance for free, plus some other style choices that the Black team sees as helpful for making maintainable code.</p><p><strong>4.Flake8</strong></p><p><strong>Flake8</strong> is a wrapper around these tools:</p><ul><li>pyflakes</li><li>pycodestyle</li><li>Ned Batchelder’s McCabe script</li></ul><p>Flake8 runs all the tools by launching the single flake8 command. It displays the warnings in a per-file, merged output.</p><p>It is a great toolkit for checking your codebase against coding style (PEP8), programming errors (like “library imported but unused” and “Undefined name”) and to check cyclomatic complexity.</p><p><strong>Why “linting” important and why should we use it?</strong></p><p>Well… I think it is very important. The one simple reason: linting helps to prevent bugs in your program. In other words:</p><ul><li>Linting makes you a better developer by helping write a better code (checking against coding standards)</li><li>It helps prevent things like syntax errors, bad formatting, incorrect styling.</li><li>Saves time as a developer.</li><li>If you working in the team, it saves time for people who are reviewing your code.</li></ul><p><strong>5.Docker</strong></p><p>Imagine you require applications A, B, C on your server. But all these require different resources and OS versions. Now if we have a lot of space and money, we can have three different machines and run them separately. But is there a better way?</p><p><strong>Use Virtual machines</strong>. You can now create VMs on a single server and run your apps on different VMs. Life’s good.</p><p>But your VMs take a lot of time to boot up. You have different OS versions(each several GBs!) on top of the hypervisor and hence your computer becomes slow. One day you are asked to move these applications to a public cloud. In addition to that, you are supposed to have not only 3 but 300 different types of applications(rather microservices) running.</p><p><strong>Use Containers. </strong>You can now pack your application into these lightweight containers (several 100 MBs) and move them easily. You can have 100s of containers running on your original server. You can make virtual machines using these containers. You can deploy once, use anywhere.</p><p><strong>So what’s docker</strong>? It is a tool for production, management and porting of containers to put across in simple terms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*i8hQvPami1ddONaH4S6dHA.png" /></figure><p><strong>Conclusion</strong></p><p>A quick recap, I Presented, In spite of having various pros of Python language, It has cons as well. But there is a solution to every problem if you require to put your application in Production. For sure, this tutorial will help you a lot.</p><p>Happy learning! Happy Coding! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99b5ffef1bf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>