Cross-language comparison: function map and similar

Steve D'Aprano steve+python at pearwood.info
Thu Aug 24 09:59:03 EDT 2017


On Thu, 17 Aug 2017 12:53 am, Steve D'Aprano wrote:

[...]
> Are there language implementations which evaluate the result of map() (or its
> equivalent) in some order other than the obvious left-to-right first-to-last
> sequential order? Is that order guaranteed by the language, or is it an
> implementation detail?

Thanks to everyone who answered.

It also confirmed my suspicion: apart from explicitly parallel languages, and
specialised parallel versions of map, mainstream programming languages do not
treat the execution order of map() as an implementation detail.

At least not the languages which people here (reading this thread, and motivated
to reply) are familiar with.

I take this as moderate evidence that programming languages do not *actually*
treat execution order of map and equivalent as an implementation detail, even
if they reserve the right to. Instead, they generally treat it as semantically
a sequential loop[1].

Apart from explicitly parallel languages, if you want a parallel or concurrent
map, you need to either call a specialised version, or specify an execution
policy to set the execution model, or equivalent. What you can't do, in any
language mentioned here, is simply call the regular, standard map function.

Thanks again to everyone who answered, and if anyone want to point out an
exception, its not too late :-)




[1] Whether implemented as a loop, or by recursion, or something else.

-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list