Python and the need for speed

bartc bc at
Fri Apr 14 08:04:31 EDT 2017

On 14/04/2017 11:56, Chris Angelico wrote:
> On Fri, Apr 14, 2017 at 8:42 PM, bartc <bc at> wrote:
>>> Classes and decorators are not esoteric. You sound like an old man who
>>> complains about this new-fangled "telephone", and how things were so much
>>> better when we had messenger boys to deliver messages anywhere in the
>>> city.
>> These days I like code to be as simple and obvious as possible. I guess no
>> one's going to complain when it is!
> Everyone says that, but there's a stark division between two groups of people:
> 1) Those who think the code should have an obvious concrete meaning -
> that you should be able to see exactly what bits get flipped in memory
> 2) Those who think the code should have an obvious abstract meaning -
> that you should be able to see exactly what the programmer intended.
> Declarative notations like decorators can beautifully provide the
> second, even though they might obscure the first. For example:
> @app.route("/hello/<name>")
> def greet(name):
>     return f"A very warm hello to you too, {name}!"
> Nice, clean code that might be found in a Flask application. In
> concrete terms, there's a lot going on, but in abstract terms it's
> simple: when this kind of URL is requested, return this formatted
> string.
> I'm of the opinion that the concrete meaning is insignificant, and
> your code should clearly portray its abstract meaning. So classes,
> decorators, etc, etc, etc are all excellent tools for *improving*
> readability.

C++ has classes, templates and so on, all of which can be argued can 
improve readability (when you eventually find that code that actually 
does something).

But somehow it doesn't really work. Because such features are overused? 
I don't know. I do know that if I want to port some program (be it in 
Python or C++), or simply try and understand it, if I see it's full of 
class definitions or whatever, then I won't bother.

> Of course, if you feel the other way, you're most welcome to write
> everything in C.

'pseudo-code' is often the language used to describe an algorithm in 
terms that are independent of any particular language. It doesn't 
usually contain classes or decorators.


More information about the Python-list mailing list