Creating 2D coordinates map in Python

后端 未结 3 1214
眼角桃花
眼角桃花 2020-12-31 08:21

I\'m not looking for solution, I\'m looking for a better solution or just a different way to do this by using some other kind of list comprehension or something else.

<
3条回答
  •  再見小時候
    2020-12-31 09:13

    UPDATED: Added @F.J. answer in the benchmark

    The first implementation is the most pythonic way, and seems to be the fastest, too. Using 1000 for each, width and height, I register execution-times of

    1. 0.35903096199s
    2. 0.461946964264s
    3. 0.625234127045s

    @F.J 0.27s

    So yeah, his answer is the best.

提交回复
热议问题