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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Shock Result? Rust faster than Python in a single test of file parsing

1 点作者 jonquark超过 4 年前

1 comment

thiasdflkj超过 4 年前
why the `fp.readline()` and `while line:` business?<p>I don&#x27;t have a big file handy to benchmark but that pattern moves the file reading into python bytecode.<p>The canonical way to read a file line by line while counting the lines is to loop over the file (it&#x27;s automatically a line iterator) and use enumerate.<p>here is the disassembed bytecode of the respective versions<p><a href="https:&#x2F;&#x2F;pastebin.com&#x2F;Rd4g8cE2" rel="nofollow">https:&#x2F;&#x2F;pastebin.com&#x2F;Rd4g8cE2</a><p>that being said, Rust will still outrun Python overall.
评论 #24813122 未加载