TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Early speed optimizations aren’t premature

7 点作者 itamarst超过 2 年前

4 条评论

smodo超过 2 年前
I wouldn&#x27;t say using vectorized operations as opposed to for loops is such a good example. You&#x27;re simply using the right tool for the job. Is using a fork to eat soup suboptimal? Is switching to a spoon optimizing the way you eat?<p>But what about using a dict or a list or tuple? That kind of decision can make a performance difference down the road, and there are trade offs in ease of development.<p>Anyway, the whole thing feels a little contrived. Who would ever argue that you shouldn&#x27;t use numpy from the get-go? Who is the author arguing against?
评论 #33373943 未加载
mattkrause超过 2 年前
This article would be more convincing if the NumPy version were actually vectorized. Replace the for-loop with<p><pre><code> result = (arr - min_val) &#x2F; (max_val - min_val) </code></pre> That should often run faster <i>and</i> removes the allocation and for-loop, so it&#x27;s easier to read.
评论 #33385331 未加载
lupire超过 2 年前
Like most comtrarian articles, it is only meaningful if you haven&#x27;t read the original, which it isn&#x27;t actually contradicting.<p><a href="https:&#x2F;&#x2F;softwareengineering.stackexchange.com&#x2F;questions&#x2F;80084&#x2F;is-premature-optimization-really-the-root-of-all-evil&#x2F;80092#80092" rel="nofollow">https:&#x2F;&#x2F;softwareengineering.stackexchange.com&#x2F;questions&#x2F;8008...</a>
rurban超过 2 年前
Of course. Just engage into mature speed optimizations from the beginning, as everyone else.