Performance of map vs starmap.
Steve D'Aprano
steve+python at pearwood.info
Tue Oct 31 13:10:17 EDT 2017
On Mon, 30 Oct 2017 09:10 pm, Kirill Balunov wrote:
> Sometime ago I asked this question at SO [1], and among the responses
> received was paragraph:
>
> - `zip` re-uses the returned `tuple` if it has a reference count of 1 when
> the `__next__` call is made.
> - `map` build a new `tuple` that is passed to the mapped function every
> time a `__next__` call is made.
>
> Why can not `map` use the same approach as `zip`?
It possibly could, if somebody could be bothered to make that
micro-optimization.
--
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