Python and the need for speed

bart4858 at gmail.com bart4858 at gmail.com
Wed Apr 12 09:44:19 EDT 2017


On Wednesday, 12 April 2017 12:56:32 UTC+1, Jussi Piitulainen  wrote:
> bartc writes:
> 

> > These are straightforward language enhancements.
> 
> FYI, the question is not how to optimize the code but how to prevent the
> programmer from writing stupid code in the first place. Someone
> suggested that a language should do that.

The 'stupid code' thing is a red herring. I assume the code people write is there for a reason.

But the language can also play a part in not allowing certain things to be expressed naturally. So the for-loop in the example has to have a control-variable even if it's not referenced.

There is no 'case' or 'switch' statement to test one expression against multiple possibilities; usually the suggestion is to use a Dict, more of a heavyweight feature of unknown efficiency. You can't take a numeric constant and give it a name, without turning it into a global variable which now needs a lookup and which can't be folded with other constants.

It seems Python completely disregards the question of efficiency, leaving that minor detail to implementations. But they can only work with what the language provides.

-- 
bartc


More information about the Python-list mailing list