Problems I Have with Python
&gt; The standard interpreter bring rather slow;<p>I&#x27;m tired about this one.<p>In the last 13 years, 97% if the projects I worked on didn&#x27;t need Python to be any faster, it was not the bottleneck. The remaining ones could leverage some solution to bypass the problem. Python speed is indeed an issue to a few people, but it&#x27;s not the red flag I can read about here and there.<p>I&#x27;ve been hearing this argument for ever. PHP is slow. Java is slow. The first one powered the Web for 10 years, the second one is the most used language is the world. A lot of time this argument is like hearing &quot;I want a pony&quot;.<p>Actually the rare persons I met really needing speed never complained. They are usually hardcore professionals, and are already working on solutions.<p>Let&#x27;s now talk about solutions.<p>Python is an interpretted and very dynamic language. It&#x27;s though to speed up. If you look at the C code, you&#x27;ll see the Python VM is quite well optimized already.<p>Now the author says:<p>&gt;  no real improvements are being made for some reason<p>But there have been:<p>- psyco<p>- unladden shallow<p>- stackless<p>- numpy and a lot of compiled extensions<p>- pypy<p>- pyston<p>- pyjion<p>- nuikta<p>- cython<p>- numba<p>People ARE actively working at the problem. It&#x27;s a HARD problem which is why we don&#x27;t have yet a definitive solution. And a lot of people working on it are non paid for this.<p>Yeah, JS became faster. You know how ? Google spent millions and hire a bunch of geniuses just to do it.<p>In 2011, the Python Software Foundation had ‎$750,000 to spend for the whole operation, including maintaint pypi, the documentation, the official website, the conferences they do and the various grants they provide. Even the few dev that are paid to work on Python (e.g: Guido) have to do it only part time.<p>So the authors worked with Python for 10 years. He made a living out of a free exceptional software and complain about a problem he may even doesn&#x27;t have while people are working their ass off to solve it. And we writes an aggressive rant about it.<p>&gt; Parallelism is very bad on CPython and PyPy<p>Yes, again, this is a HARD problem. Python is very old. Older than Java. We only had multi-core recently. We can&#x27;t destroy mono-core perfs to get multi-core, and have to mainteaint a legacy code base.<p>We also have:<p>- a good multiprocessig story;<p>- 2 good async stories;<p>- tooling to pre-spaws, manage and scales processes;<p>- tooling to create task queues.<p>So while the community is trying, for free, to solve the problem. We have solutions. It&#x27;s not perfect. But again what&#x27;s the point of complaining like an hungry child à 4 o&#x27;clock unhappy it&#x27;s not yet dinner time ?<p>&gt; asyncio does not seem very well integrated, and does not seem as useful as libraries like eventlet. They seem to have wanted to reinvent Twisted, but did so half-assed and did not include useful protocols (Twisted has line-based protocols, HTTP, etc. built in and easily subclassable.)<p>What is he talking about we just got it ? How do you expect it to be well integrated yet ?<p>And Twisted is a framework (a very hard to use one) while asyncio is a low level lib.<p>eventlet doesn&#x27;t let you choose where to switch context, it&#x27;s basically like threads. We already have threads.<p>&gt; Quite a few legacy projects are written in Python 2, and it can take some work to port them. This is particularly a pain for libraries where I expect to pip install them and have them &quot;Just Work&quot;.<p>When the last time didn&#x27;t that happen for anybody ?<p>Seriously:<p><a href="http:&#x2F;&#x2F;py3readiness.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;py3readiness.org&#x2F;</a><p>I&#x27;ve been coded in Python 3 for the last 2 years. It happened twice. Both time I was able to convert the code base in a few minutes. I said minutes. Not hours.<p>&gt; There is an official tool 2to3 which does not work in all cases.<p>And the break in your car doesn&#x27;t work in all cases either. Still it&#x27;s a nice break.<p>Plus you got six and Python-future. Converting any pure-python code base is not hard. Compiled extension is harder, but my guess the author never needed to code one.<p>And i&#x27;ll say it again...<p>People have 15 bloody years to migrates. It&#x27;s not like JS tools breaking every 3 months. It&#x27;s not like PHP skipping the version 6 or Perl taking 10 years to get V6.<p>No. Python 3 arrived quickly after many warnings. Then tools, tutorials and a looooooooooooot of time have been provided.<p>This is nowhere Python&#x27;s fault. It&#x27;s the best damn migration story I&#x27;ve ever witnessed in my life.<p>My only grudge on Python 3 is that it didn&#x27;t break ENOUGH. I wished for stuff to have changed more.<p>&gt; The standard library is sometimes inconsistent<p>One of my pet peeves as well.<p>&gt; The BDFL himself, Guido van Rossum, has infamously declared that he does not like functional programming (odd, considering the language is built around FP concepts), and that map&#x2F;reduce&#x2F;filter should not be in the language. Well -- in my opinion that is a grave mistake, but more importantly the language suffers.<p>The author doesn&#x27;t like the style of the language. So it&#x27;s a matter of taste.<p>Well I like it that way.<p>Now what ?<p>&gt; reduce is now tucked away inside the functools module (as of Python 3), even though it is the only one of map&#x2F;filter that is not replaceable by list&#x2F;set&#x2F;dict comprehensions! Yet map and filter are still in the base global environment. What sense does that make?<p>Yes it does because reduce is seldom used. Grep github and you&#x27;ll see. map and filter are still in the built-ins because people like the author complained a lot on the mailing list.<p>Yet, the majority of code base I read, including most of the libs I use (I spend a lot of time reading the content of my site-packages) don&#x27;t use map&#x2F;filter since we got comprehensions.<p>&gt; I often find myself reimplementing flatten as flatten = lambda xs: itertools.chain.from_iterable(*xs)<p>Use comprehensions to flatten. Learn you language for van Rossum&#x27; sake !<p>(y for x in xs for y in x)<p>&gt; The lack of tail call optimization in most implementations makes writing tail recursive algorithms rather pointless, unfortunately, even when they may be more legible than their iterative counterparts.<p>&gt; There is no standard way (even in functools) to compose functions. There is partial application via functools.partial, at least...<p>Again it&#x27;s because recursivity is not encouraged in Python. It&#x27;s the philosophy of the language. One can dislike it but it&#x27;s not a Python problem, it&#x27;s a Python decision.<p>I stay in Python precisely for this. Everytime I go read functional heavy code, it&#x27;s hard to read. I&#x27;m an expert coder and trainer. I&#x27;m paid up to 900€&#x2F;day. Most code should be easy to understand given my experience. When it&#x27;s not, I consider that a bug.<p>Functional lovers write smart code. I hate reading smart code. I want code that is easy to debug.<p>If you really need TCO, like when implementing a state machine, there are solutions:<p><a href="http:&#x2F;&#x2F;neopythonic.blogspot.fr&#x2F;2009&#x2F;04&#x2F;final-words-on-tail-calls.html" rel="nofollow">http:&#x2F;&#x2F;neopythonic.blogspot.fr&#x2F;2009&#x2F;04&#x2F;final-words-on-tail-c...</a><p>Not as elegant, but good enough since it&#x27;s a rare occurence you do need it. Again. Rare.<p>The language is optimized for regular use cases and readability, not smart formulas.<p>&gt; Lambda is awful<p>Lambda is wonderful. It keeps people from writting budge inline callback like they do everywhere else. It&#x27;s the best decision Guido every took.<p>Xith lambda + decorators + list comprehension, the need for multi-lines callbacks is not huge.<p>You want more ? Write a regular function. How hard is it ?<p>It&#x27;s not hard. So eventually it&#x27;s matter of...<p>... wait for it ...<p>taste.<p>I would have liked a shorter keyword though. But I can live with it.<p>&gt; Inadequate data modelling facilities<p>&quot;Inadequate data modelling facilities&quot; because classes are verboses ? Overkill title much ?<p>Beside, if you just need a container, you use a dict in Python. Not a class. At most you use SimpleNamespace:<p>&gt;&gt;&gt; from types import SimpleNamespace
&gt;&gt;&gt; SimpleNamespace(a=1, b=True)
namespace(a=1, b=True)<p>But again this is &quot;pony&quot;-worth complaining.<p>I do think classes are too verbose in Python (I use the attrs lib because of this). But this is childish.<p>algebraic data type and the whole dunder methods vs interfaces are more interesting debates.<p>&gt; Lack of switch (or match)<p>&gt; No, dicts with lambdas (see above) are not a replacement. No, long if-else chains are not a replacement. I want a nice way to match on data (preferably richly -- as with ADTs, ranges, ...) and associate matches with logic<p>Yes they are for switch. Since is the most overrated statement after go to. It&#x27;s uneeded, as you can express it&#x27;s logic perfectly without it. And again, &quot;rare use case&quot;. There is nothing wrong with a bunch of if or a dict.<p>Now for match, it&#x27;s a different story. Pattern matching would be a nice addition for Python IMO. But again things like:<p>&gt; Please do not suggest awful hacks to do this, and fix your language instead.<p>Is arrogant and ignorant.<p>The mailling list have been discussing it for years. It hasn&#x27;t happen because there no such thing as a magic way to make everybody agree then implement it and maintain it for free.<p>Things have cost. People have taste. Code base have legacy requirements.