{"id":381,"date":"2016-03-08T09:00:46","date_gmt":"2016-03-08T17:00:46","guid":{"rendered":"http:\/\/blogs.msdn.microsoft.com\/pythonengineering\/?p=381"},"modified":"2019-02-17T15:27:11","modified_gmt":"2019-02-17T22:27:11","slug":"python-3-is-winning","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-3-is-winning\/","title":{"rendered":"Python 3 is Winning Library Developer Support"},"content":{"rendered":"<p><a href=\"https:\/\/aka.ms\/py3winningnb\" target=\"_blank\"><img decoding=\"async\" class=\"alignnone size-full wp-image-452\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2016\/03\/Launch-Notebook-Now-3.png\" alt=\"Launch Notebook Now!\" width=\"338\" height=\"50\" \/><\/a><\/p>\n<p>https:\/\/notebooks.azure.com\/library\/rJUgQ81mnpo<\/p>\n<p><strong>In 3 months, Python 3 will be better supported than Python 2.<\/strong><\/p>\n<p>Are you using Python 3 for your development? It has been out for 7+ years at this point. So, if you aren&#8217;t using it, why not? Since December of 2008, the initial release of Python 3, it seems the new version of Python has lived in the shadow of Python 2. And here we are, 7 years later, still looking at a world where people are using Python 2 and talking about how Python 3 doesn&#8217;t work for them.<\/p>\n<p>This made me wonder. Is Python 3 really inferior to Python 2? If not, why aren&#8217;t people moving? I mean, there has to be a reason people are still clinging to the older technology. After some thought, it seemed to me the most recurring statement for why people are continuing to use Python 2 was &#8220;the packages I need just aren&#8217;t on Python 3&#8221;. In attempt to get a statement I believed I could measure I framed this as &#8220;is Python 3 supported by library developers well enough for me to move?&#8221;.<\/p>\n<p>So, I wrote a <a href=\"https:\/\/github.com\/crwilcox\/PyPI-Gatherer\">worker role in Azure<\/a>, collected a bunch of data from <a href=\"http:\/\/pypi.python.org\">PyPI<\/a>,\u00a0and got to analyzing all of it in a <a title=\"Jupyter Notebook on Cortana Analytics Gallery\" href=\"https:\/\/aka.ms\/py3winningnb\" target=\"_blank\">Jupyter Notebook (Cortana Analytics Gallery)<\/a>.\u00a0Is the Python 3 library space being maintained well or is Python 2 still the kingpin? Python 3 has around 4 years to become the only supported version of Python, as Python 2 Support is being discontinued as the version goes EOL (End of Life). Does PyPI indicate that we will be ready? Let&#8217;s examine the data and determine what the future may hold.<\/p>\n<p>To see the full analysis you can get the <a title=\"Jupyter Notebook on Cortana Analytics Gallery\" href=\"https:\/\/aka.ms\/py3winningnb\" target=\"_blank\">Jupyter Notebook for this post<\/a>\u00a0from the Cortana Analytics Gallery.<\/p>\n<p><b>Getting the Data: PyPI, and Trove Classifiers, and an Azure Service<\/b><\/p>\n<p>PyPI allows package maintainers to mark their releases with <a title=\"List of Trove Classifiers on PyPI\" href=\"https:\/\/pypi.python.org\/pypi?%3Aaction=list_classifiers\" target=\"_blank\">trove classifiers<\/a>\u00a0to indicate what they support. I wrote an Azure Cloud Service to gather the data from PyPI and store it in <a title=\"Python Azure Storage Library\" href=\"https:\/\/pypi.python.org\/pypi\/azure-storage\" target=\"_blank\">Azure Table Storage<\/a>\u00a0for\u00a0analysis later. This service, by monitoring the RSS feed for PyPI, uses\u00a0<a href=\"https:\/\/pypi.python.org\/pypi\/requests\" target=\"_blank\">Requests<\/a>\u00a0and\u00a0the <a href=\"https:\/\/pypi.python.org\/pypi\/azure\" target=\"_blank\">Azure SDK for Python<\/a>.\u00a0 If you are interested further in the collection process you can find the source on\u00a0<a title=\"PyPI Data Gatherer Cloud Service Code\" href=\"https:\/\/github.com\/crwilcox\/PyPI-Gatherer\" target=\"_blank\">GitHub<\/a>.<\/p>\n<p>The versions\/releases show the activity of any package, which admittedly means that if a single package made a huge proportion of releases within a month it could skew the data. Since I think this is unlikely, and not really worse than a single package being downloaded a disproportionate amount (which is the problem with most analysis on the consumption side), I ran with it. Once collected the data can indicate, based on what package authors are releasing support for,\u00a0an overall trend of adoption.<\/p>\n<p>There are a variety of blogs using user download trends from the <a title=\"PyPI\" href=\"https:\/\/pypi.python.org\" target=\"_blank\">Python Package Index<\/a> (PyPI) when determining the success of Python 3. To figure out if Python 3 is better supported we will look at the package maintenance and publishing activity instead of <a title=\"A Year of PyPI Downloads\" href=\"https:\/\/caremad.io\/2015\/04\/a-year-of-pypi-downloads\/\" target=\"_blank\">looking at download counts<\/a>. This way, we get to look at a leading indicator of adoption, the package creation, instead of a trailing indicator, the package download. Using package creation we can find that a world where Python 3 is better supported isn&#8217;t far away.<\/p>\n<p><b>Analyzing the Data<\/b><\/p>\n<p>Once collected we\u00a0can investigate the data using <a href=\"http:\/\/jupyter.org\/\" target=\"_blank\">Jupyter<\/a> and <a href=\"https:\/\/pypi.python.org\/pypi\/pandas\" target=\"_blank\">Pandas<\/a> and chart our findings. The question we hope to answer is whether we are approaching the goal of the vast majority of active Python packages supporting Python 3 fast enough to meet the 2020 EOL of Python 2.<\/p>\n<p>By using a Jupyter Notebook, Pandas, and the data we collected earlier, Python 2 and Python 3 package development\u00a0can be charted\u00a0to determine what trends may exist. If you want to see further charts and analysis you can view the complete\u00a0<a href=\"https:\/\/aka.ms\/py3winningnb\" target=\"_blank\">Jupyter Notebook<\/a>. For this post though I want to focus on two charts; uploaded packages over the past five years, and the trend lines found for Python 2 and Python 3 package version uploads.<\/p>\n<p><em><b>Takeaway #1: Uploaded Packages are increasingly containing Python 3 Support and decreasingly containing Python 2 support.<\/b><\/em><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/12\/2019\/02\/pypi-chart-1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-384\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2016\/03\/pypi-chart-1-2.png\" alt=\"pypi-chart-1\" width=\"840\" height=\"354\" \/><\/a><\/p>\n<p>Above is a chart showing the past 5 years of package versions. What we can see is Python 2 (Only) packages are decreasing and Python 3 support is gaining. Soon enough, we will see a larger number of Python 3 packages than Python 2 packages.<\/p>\n<p><em><b>Takeaway #2: Python 3 support is set to overtake Python 2 support and it isn&#8217;t as far away as you might think.<\/b><\/em><\/p>\n<p>Below is one chart from this analysis. It contains the percentage of packages published to PyPI marked with either Python 3 or Python 2 support. Since packages can be marked both these don&#8217;t add to 100%. The red line represents Python 2 and the blue line represents Python 3 charted from September 28, 2012 (1.35e9) to present day (1.46e9) using Epoch Time.<\/p>\n<p>Percentage of Python 2 and Python 3 Packages over Time (Epoch)<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-394\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2016\/03\/pypi-chart-2-1.png\" alt=\"pypi-chart-2\" width=\"377\" height=\"265\" \/><\/p>\n<p>What you can see in the chart is Python 3 support is converging with Python 2 support. If you project those fit-lines out and do some simple algebra we find that they cross around May of this year.<\/p>\n<p><b>Conclusion: The state of things<\/b><\/p>\n<p>More precisely, when run with the data available as of February 22, 2016 the analysis returned a date of May 21, 2016 for Python 3 to be better supported than Python 2.\u00a0 Now, this doesn&#8217;t include packages that aren&#8217;t classified with trove classifiers. It also gives higher weight to maintained packages. This date seems optimistic but the data is certainly pointing at Python 3 taking over in the very near future.<\/p>\n<p>It also seems safe to say that, by 2020, there will be plenty of Python 3 packages and that dependencies blocking one&#8217;s transition to Python 3 should not be a significant problem for most people.<\/p>\n<p><em><strong>Analyze the data yourself!<\/strong><\/em><\/p>\n<p>I think it would be unfair though to just give you two charts. You can find the complete data and analysis in a\u00a0<a title=\"Jupyter Notebook\" href=\"https:\/\/aka.ms\/py3winningnb\" target=\"_blank\">Jupyter Notebook published to the Cortana Analytics Gallery<\/a>. It goes into more depth about the data analysis and contains many more charts\/plots than what is shown in this post. I encourage you to run the notebook, experiment with the data yourself, and come to your own conclusions. If you find something interesting feel free to share!<\/p>\n<p><a href=\"https:\/\/aka.ms\/py3winningnb\" target=\"_blank\"><img decoding=\"async\" class=\"alignnone size-full wp-image-452\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2016\/03\/Launch-Notebook-Now-3.png\" alt=\"Launch Notebook Now!\" width=\"338\" height=\"50\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/notebooks.azure.com\/library\/rJUgQ81mnpo In 3 months, Python 3 will be better supported than Python 2. Are you using Python 3 for your development? It has been out for 7+ years at this point. So, if you aren&#8217;t using it, why not? Since December of 2008, the initial release of Python 3, it seems the new version of [&hellip;]<\/p>\n","protected":false},"author":382,"featured_media":10119,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[8,14],"class_list":["post-381","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jupyter","tag-azure-notebooks","tag-jupyter"],"acf":[],"blog_post_summary":"<p>https:\/\/notebooks.azure.com\/library\/rJUgQ81mnpo In 3 months, Python 3 will be better supported than Python 2. Are you using Python 3 for your development? It has been out for 7+ years at this point. So, if you aren&#8217;t using it, why not? Since December of 2008, the initial release of Python 3, it seems the new version of [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/users\/382"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/comments?post=381"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/381\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media\/10119"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media?parent=381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}