Python and the need for speed

bartc bc at freeuk.com
Fri Apr 14 06:42:39 EDT 2017


On 14/04/2017 03:13, Steve D'Aprano wrote:
> On Wed, 12 Apr 2017 07:56 pm, bart4858 at gmail.com wrote:

> if you care most about program correctness, type-safety and
> correctness proofs, choosing C is probably the wrong decision.

CPython is written in C; bad choice?

>> (** Although I find code full of class definitions, one-liners, decorators
>> and all the other esoterics, [incomprehensible]... I'm not the only
>> one, so perhaps readability isn't too much of a priority either.)
>
> 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!

> I'm not sure what you consider incomprehensible about "one liners", surely
> it depends on what the one liner does. These are pretty clear to me:
>
> # The archetypal "Hello World!" program is a one-liner.
> print("Hello World!")
>
> # One liner to calculate the sum of the first 50 cubes.
> total = sum(i**3 for i in range(50))

Those are fine. I means when lots of things are arranged on one line, 
where the output of one method feeds into the next.

Vertical space is free after all.

However, you might argue that having discrete, intermediate steps would 
be a little slower than one-lining..

-- 
bartc



More information about the Python-list mailing list